@samchon/openapi
Advanced tools
Comparing version 2.0.0-dev.20241202-2 to 2.0.0
import { OpenApi } from "../OpenApi"; | ||
/** | ||
* OpenAPI schema related error. | ||
* | ||
* `IOpenApiSchemaError` is a type representing an error that occured during the | ||
* iteration or transformation of the OpenAPI schema (JSON schema) of | ||
* {@link OpenApi.IJsonSchema} type. | ||
* | ||
* The most `IOpenApiSchemaError` is occured by the transformation process from | ||
* {@link OpenApi.IJsonSchema} to {@link ILlmSchema} type. The transformation can | ||
* be failed by following reasons: | ||
* | ||
* - Unable to find the {@link OpenApi.IJsonSchema.IReference} directing. | ||
* - Non-supported type in LLM schema models | ||
* - Every models do not support {@link OpenApi.IJsonSchema.ITuple} | ||
* - Gemini does not support {@link OpenApi.IJsonSchema.IOneOf} | ||
* - ChatGPT and Gemini do not support {@link OpenApi.IJsonSchema.IObject.additionalProperties} | ||
* | ||
* @author Jeongho Nam - https://github.com/samchon | ||
*/ | ||
export interface IOpenApiSchemaError { | ||
/** | ||
* Method that caused the error. | ||
*/ | ||
method: string; | ||
/** | ||
* Message of the error. | ||
*/ | ||
message: string; | ||
/** | ||
* The detailed reasons of the error. | ||
*/ | ||
reasons: IOpenApiSchemaError.IReason[]; | ||
} | ||
export declare namespace IOpenApiSchemaError { | ||
/** | ||
* Detailed reason of the error. | ||
*/ | ||
interface IReason { | ||
/** | ||
* Schema that caused the error. | ||
*/ | ||
schema: OpenApi.IJsonSchema; | ||
/** | ||
* Accessor to the schema. | ||
*/ | ||
accessor: string; | ||
/** | ||
* Message of the reason. | ||
*/ | ||
message: string; | ||
} | ||
} |
@@ -0,11 +1,43 @@ | ||
/** | ||
* Result of an operation that can either succeed or fail. | ||
* | ||
* `IResult` is an union type that represents the result of an operation | ||
* that can either succeed or fail. | ||
* | ||
* You can distinguise the result by checking the {@link IResult.success} value, | ||
* and if it's `true`, the success value is stored in {@link IResult.value}. | ||
* Otherwise, if it's `false`, the error value is stored in {@link IResult.error}. | ||
* | ||
* @template T Type of the success value. | ||
* @template E Type of the error value. | ||
* @author Jeongho Nam - https://github.com/samchon | ||
*/ | ||
export type IResult<T, E> = IResult.ISuccess<T> | IResult.IFailure<E>; | ||
export declare namespace IResult { | ||
/** | ||
* Success type of {@link IResult}. | ||
*/ | ||
interface ISuccess<T> { | ||
/** | ||
* Success flag. | ||
*/ | ||
success: true; | ||
/** | ||
* Success value. | ||
*/ | ||
value: T; | ||
} | ||
/** | ||
* Failure type of {@link IResult}. | ||
*/ | ||
interface IFailure<E> { | ||
/** | ||
* Success flag. | ||
*/ | ||
success: false; | ||
/** | ||
* The error value. | ||
*/ | ||
error: E; | ||
} | ||
} |
import { IChatGptSchema } from "../structures/IChatGptSchema"; | ||
export declare namespace ChatGptTypeChecker { | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
const isNull: (schema: IChatGptSchema) => schema is IChatGptSchema.INull; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
const isUnknown: (schema: IChatGptSchema) => schema is IChatGptSchema.IUnknown; | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
const isBoolean: (schema: IChatGptSchema) => schema is IChatGptSchema.IBoolean; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
const isInteger: (schema: IChatGptSchema) => schema is IChatGptSchema.IInteger; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
const isNumber: (schema: IChatGptSchema) => schema is IChatGptSchema.INumber; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
const isString: (schema: IChatGptSchema) => schema is IChatGptSchema.IString; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
const isArray: (schema: IChatGptSchema) => schema is IChatGptSchema.IArray; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
const isObject: (schema: IChatGptSchema) => schema is IChatGptSchema.IObject; | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
const isReference: (schema: IChatGptSchema) => schema is IChatGptSchema.IReference; | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
const isAnyOf: (schema: IChatGptSchema) => schema is IChatGptSchema.IAnyOf; | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link IChatGptSchema.IAnyOf.anyOf} | ||
* - {@link IChatGptSchema.IReference} | ||
* - {@link IChatGptSchema.IObject.properties} | ||
* - {@link IChatGptSchema.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
const visit: (props: { | ||
@@ -20,2 +94,8 @@ closure: (schema: IChatGptSchema, accessor: string) => void; | ||
}) => void; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
const covers: (props: { | ||
@@ -22,0 +102,0 @@ $defs?: Record<string, IChatGptSchema> | undefined; |
@@ -37,5 +37,17 @@ "use strict"; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
ChatGptTypeChecker.isNull = function (schema) { | ||
return schema.type === "null"; | ||
}; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
ChatGptTypeChecker.isUnknown = function (schema) { | ||
@@ -46,14 +58,44 @@ return schema.type === undefined && | ||
}; | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
ChatGptTypeChecker.isBoolean = function (schema) { | ||
return schema.type === "boolean"; | ||
}; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
ChatGptTypeChecker.isInteger = function (schema) { | ||
return schema.type === "integer"; | ||
}; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
ChatGptTypeChecker.isNumber = function (schema) { | ||
return schema.type === "number"; | ||
}; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
ChatGptTypeChecker.isString = function (schema) { | ||
return schema.type === "string"; | ||
}; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
ChatGptTypeChecker.isArray = function (schema) { | ||
@@ -63,6 +105,24 @@ return schema.type === "array" && | ||
}; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
ChatGptTypeChecker.isObject = function (schema) { | ||
return schema.type === "object"; | ||
}; | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
ChatGptTypeChecker.isReference = function (schema) { return schema.$ref !== undefined; }; | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
ChatGptTypeChecker.isAnyOf = function (schema) { | ||
@@ -74,2 +134,16 @@ return schema.anyOf !== undefined; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link IChatGptSchema.IAnyOf.anyOf} | ||
* - {@link IChatGptSchema.IReference} | ||
* - {@link IChatGptSchema.IObject.properties} | ||
* - {@link IChatGptSchema.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
ChatGptTypeChecker.visit = function (props) { | ||
@@ -113,2 +187,8 @@ var _a, _b; | ||
}; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
ChatGptTypeChecker.covers = function (props) { | ||
@@ -115,0 +195,0 @@ return coverStation({ |
@@ -10,2 +10,14 @@ import { IGeminiSchema } from "../structures/IGeminiSchema"; | ||
export declare namespace GeminiTypeChecker { | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link IGeminiSchema.IObject.properties} | ||
* - {@link IGeminiSchema.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
const visit: (props: { | ||
@@ -16,11 +28,72 @@ closure: (schema: IGeminiSchema, accessor: string) => void; | ||
}) => void; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
const covers: (x: IGeminiSchema, y: IGeminiSchema) => boolean; | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
const isBoolean: (schema: IGeminiSchema) => schema is IGeminiSchema.IBoolean; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
const isInteger: (schema: IGeminiSchema) => schema is IGeminiSchema.IInteger; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
const isNumber: (schema: IGeminiSchema) => schema is IGeminiSchema.INumber; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
const isString: (schema: IGeminiSchema) => schema is IGeminiSchema.IString; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
const isArray: (schema: IGeminiSchema) => schema is IGeminiSchema.IArray; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
const isObject: (schema: IGeminiSchema) => schema is IGeminiSchema.IObject; | ||
/** | ||
* Test whether the schema is a null type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
const isNullOnly: (schema: IGeminiSchema) => schema is IGeminiSchema.INullOnly; | ||
/** | ||
* Test whether the schema is a nullable type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether nullable type or not | ||
*/ | ||
const isNullable: (schema: IGeminiSchema) => boolean; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
const isUnknown: (schema: IGeminiSchema) => schema is IGeminiSchema.IUnknown; | ||
} |
@@ -32,2 +32,14 @@ "use strict"; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link IGeminiSchema.IObject.properties} | ||
* - {@link IGeminiSchema.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
GeminiTypeChecker.visit = function (props) { | ||
@@ -53,2 +65,8 @@ var _a, _b; | ||
}; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
GeminiTypeChecker.covers = function (x, y) { | ||
@@ -139,23 +157,80 @@ // CHECK EQUALITY | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
GeminiTypeChecker.isBoolean = function (schema) { | ||
return schema.type === "boolean"; | ||
}; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
GeminiTypeChecker.isInteger = function (schema) { | ||
return schema.type === "integer"; | ||
}; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
GeminiTypeChecker.isNumber = function (schema) { | ||
return schema.type === "number"; | ||
}; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
GeminiTypeChecker.isString = function (schema) { | ||
return schema.type === "string"; | ||
}; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
GeminiTypeChecker.isArray = function (schema) { | ||
return schema.type === "array"; | ||
}; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
GeminiTypeChecker.isObject = function (schema) { | ||
return schema.type === "object"; | ||
}; | ||
/** | ||
* Test whether the schema is a null type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
GeminiTypeChecker.isNullOnly = function (schema) { | ||
return schema.type === "null"; | ||
}; | ||
/** | ||
* Test whether the schema is a nullable type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether nullable type or not | ||
*/ | ||
GeminiTypeChecker.isNullable = function (schema) { | ||
return !GeminiTypeChecker.isUnknown(schema) && (GeminiTypeChecker.isNullOnly(schema) || schema.nullable === true); | ||
}; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
GeminiTypeChecker.isUnknown = function (schema) { | ||
@@ -162,0 +237,0 @@ return schema.type === undefined; |
import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1"; | ||
export declare namespace LlmTypeCheckerV3_1 { | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
const isNull: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.INull; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
const isUnknown: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IUnknown; | ||
/** | ||
* Test whether the schema is a constant type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether constant type or not | ||
*/ | ||
const isConstant: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IConstant; | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
const isBoolean: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IBoolean; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
const isInteger: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IInteger; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
const isNumber: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.INumber; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
const isString: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IString; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
const isArray: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IArray; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
const isObject: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IObject; | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
const isReference: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IReference; | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
const isOneOf: (schema: ILlmSchemaV3_1) => schema is ILlmSchemaV3_1.IOneOf; | ||
/** | ||
* Test whether the schema is recursive reference type. | ||
* | ||
* Test whether the target schema is a reference type, and test one thign more | ||
* that the reference is self-recursive or not. | ||
* | ||
* @param props Properties for recursive reference test | ||
* @returns Whether the schema is recursive reference type or not | ||
*/ | ||
const isRecursiveReference: (props: { | ||
@@ -18,2 +93,8 @@ $defs?: Record<string, ILlmSchemaV3_1>; | ||
}) => boolean; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
const covers: (props: { | ||
@@ -24,2 +105,17 @@ $defs?: Record<string, ILlmSchemaV3_1>; | ||
}) => boolean; | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link ILlmSchemaV3_1.IOneOf.oneOf} | ||
* - {@link ILlmSchemaV3_1.IReference} | ||
* - {@link ILlmSchemaV3_1.IObject.properties} | ||
* - {@link ILlmSchemaV3_1.IObject.additionalProperties} | ||
* - {@link ILlmSchemaV3_1.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
const visit: (props: { | ||
@@ -26,0 +122,0 @@ closure: (schema: ILlmSchemaV3_1, accessor: string) => void; |
@@ -10,29 +10,104 @@ "use strict"; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isNull = function (schema) { return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isNull(schema); }; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isUnknown = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isUnknown(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a constant type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether constant type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isConstant = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isConstant(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isBoolean = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isBoolean(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isInteger = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isInteger(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isNumber = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isNumber(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isString = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isString(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isArray = function (schema) { return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isArray(schema); }; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isObject = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isObject(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isReference = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isReference(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isOneOf = function (schema) { return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isOneOf(schema); }; | ||
/** | ||
* Test whether the schema is recursive reference type. | ||
* | ||
* Test whether the target schema is a reference type, and test one thign more | ||
* that the reference is self-recursive or not. | ||
* | ||
* @param props Properties for recursive reference test | ||
* @returns Whether the schema is recursive reference type or not | ||
*/ | ||
LlmTypeCheckerV3_1.isRecursiveReference = function (props) { | ||
@@ -50,2 +125,8 @@ return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isRecursiveReference({ | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
LlmTypeCheckerV3_1.covers = function (props) { | ||
@@ -61,2 +142,17 @@ return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.covers({ | ||
}; | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link ILlmSchemaV3_1.IOneOf.oneOf} | ||
* - {@link ILlmSchemaV3_1.IReference} | ||
* - {@link ILlmSchemaV3_1.IObject.properties} | ||
* - {@link ILlmSchemaV3_1.IObject.additionalProperties} | ||
* - {@link ILlmSchemaV3_1.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
LlmTypeCheckerV3_1.visit = function (props) { | ||
@@ -63,0 +159,0 @@ return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.visit({ |
@@ -13,11 +13,11 @@ import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3"; | ||
* | ||
* Visit every nested schemas of the target, and apply the callback function | ||
* to them. | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* If the visitor meets an union type, it will visit every individual schemas | ||
* in the union type. Otherwise meets an object type, it will visit every | ||
* properties and additional properties. If the visitor meets an array type, | ||
* it will visit the item type. | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* @param props Target and callback function | ||
* - {@link ILlmSchemaV3.IOneOf.oneOf} | ||
* - {@link ILlmSchemaV3.IObject.additionalProperties} | ||
* - {@link ILlmSchemaV3.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
@@ -24,0 +24,0 @@ const visit: (props: { |
@@ -46,11 +46,11 @@ "use strict"; | ||
* | ||
* Visit every nested schemas of the target, and apply the callback function | ||
* to them. | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* If the visitor meets an union type, it will visit every individual schemas | ||
* in the union type. Otherwise meets an object type, it will visit every | ||
* properties and additional properties. If the visitor meets an array type, | ||
* it will visit the item type. | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* @param props Target and callback function | ||
* - {@link ILlmSchemaV3.IOneOf.oneOf} | ||
* - {@link ILlmSchemaV3.IObject.additionalProperties} | ||
* - {@link ILlmSchemaV3.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
@@ -57,0 +57,0 @@ LlmTypeCheckerV3.visit = function (props) { |
import { OpenApi } from "../OpenApi"; | ||
import { IOpenApiSchemaError } from "../structures/IOpenApiSchemaError"; | ||
import { IResult } from "../typings/IResult"; | ||
/** | ||
* Type checker of OpenAPI type schema. | ||
* | ||
* `OpenApiTypeChecker` is a type checker of {@link OpenApi.IJsonSchema}. | ||
* | ||
* @author Jeongho Nam - https://github.com/samchon | ||
*/ | ||
export declare namespace OpenApiTypeChecker { | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
const isNull: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.INull; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
const isUnknown: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IUnknown; | ||
/** | ||
* Test whether the schema is a constant type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether constant type or not | ||
*/ | ||
const isConstant: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IConstant; | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
const isBoolean: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IBoolean; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
const isInteger: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IInteger; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
const isNumber: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.INumber; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
const isString: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IString; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
const isArray: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IArray; | ||
/** | ||
* Test whether the schema is a tuple type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether tuple type or not | ||
*/ | ||
const isTuple: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.ITuple; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
const isObject: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IObject; | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
const isReference: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IReference; | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
const isOneOf: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IOneOf; | ||
/** | ||
* Test whether the schema is recursive reference type. | ||
* | ||
* Test whether the target schema is a reference type, and test one thign more | ||
* that the reference is self-recursive or not. | ||
* | ||
* @param props Properties for recursive reference test | ||
* @returns Whether the schema is recursive reference type or not | ||
*/ | ||
const isRecursiveReference: (props: { | ||
@@ -21,2 +109,20 @@ components: OpenApi.IComponents; | ||
}) => boolean; | ||
/** | ||
* Escape from the {@link OpenApi.IJsonSchema.IReference} type. | ||
* | ||
* Escape from the {@link OpenApi.IJsonSchema.IReference} type, replacing the | ||
* every references to the actual schemas. If the escape is successfull, the returned | ||
* schema never contains any {@link OpenApi.IJsonSchema.IReference} type in its | ||
* structure. | ||
* | ||
* If the schema has a recursive reference, the recursive reference would be repeated | ||
* as much as the `props.recursive` depth. If you've configured the `props.recursive` | ||
* as `false` or `0`, it would be failed and return an {@link IOpenApiSchemaError}. | ||
* Also, if there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find | ||
* the matched type in the {@link OpenApi.IComponents.schemas}, it would also be failed | ||
* and return an {@link IOpenApiSchemaError} either. | ||
* | ||
* @param props Properties for escaping | ||
* @returns Escaped schema, or error with reason | ||
*/ | ||
const escape: (props: { | ||
@@ -29,2 +135,17 @@ components: OpenApi.IComponents; | ||
}) => IResult<OpenApi.IJsonSchema, IOpenApiSchemaError>; | ||
/** | ||
* Unreference the schema. | ||
* | ||
* Unreference the schema, replacing the {@link OpenApi.IJsonSchema.IReference} type | ||
* to the actual schema. Different with {@link escape} is, the `unreference` function | ||
* does not resolve every references in the schema, but resolve only one time. | ||
* | ||
* If there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find | ||
* the matched type in the {@link OpenApi.IComponents.schemas}, and you've called this | ||
* `unreference()` function with the reference, it would also be failed and return an | ||
* {@link IOpenApiSchemaError} value. | ||
* | ||
* @param props Properties of unreference | ||
* @returns Unreferenced schema | ||
*/ | ||
const unreference: (props: { | ||
@@ -36,2 +157,19 @@ components: OpenApi.IComponents; | ||
}) => IResult<OpenApi.IJsonSchema, IOpenApiSchemaError>; | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link OpenApi.IJsonSchema.IOneOf.oneOf} | ||
* - {@link OpenApi.IJsonSchema.IReference} | ||
* - {@link OpenApi.IJsonSchema.IObject.properties} | ||
* - {@link OpenApi.IJsonSchema.IObject.additionalProperties} | ||
* - {@link OpenApi.IJsonSchema.IArray.items} | ||
* - {@link OpenApi.IJsonSchema.ITuple.prefixItems} | ||
* - {@link OpenApi.IJsonSchema.ITuple.additionalItems} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
const visit: (props: { | ||
@@ -44,2 +182,8 @@ closure: (schema: OpenApi.IJsonSchema, accessor: string) => void; | ||
}) => void; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
const covers: (props: { | ||
@@ -46,0 +190,0 @@ components: OpenApi.IComponents; |
@@ -16,2 +16,9 @@ "use strict"; | ||
var OpenApiTypeCheckerBase_1 = require("./internal/OpenApiTypeCheckerBase"); | ||
/** | ||
* Type checker of OpenAPI type schema. | ||
* | ||
* `OpenApiTypeChecker` is a type checker of {@link OpenApi.IJsonSchema}. | ||
* | ||
* @author Jeongho Nam - https://github.com/samchon | ||
*/ | ||
var OpenApiTypeChecker; | ||
@@ -22,38 +29,119 @@ (function (OpenApiTypeChecker) { | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
OpenApiTypeChecker.isNull = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isNull(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
OpenApiTypeChecker.isUnknown = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isUnknown(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a constant type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether constant type or not | ||
*/ | ||
OpenApiTypeChecker.isConstant = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isConstant(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
OpenApiTypeChecker.isBoolean = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isBoolean(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
OpenApiTypeChecker.isInteger = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isInteger(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
OpenApiTypeChecker.isNumber = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isNumber(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
OpenApiTypeChecker.isString = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isString(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
OpenApiTypeChecker.isArray = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isArray(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a tuple type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether tuple type or not | ||
*/ | ||
OpenApiTypeChecker.isTuple = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isTuple(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
OpenApiTypeChecker.isObject = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isObject(schema); | ||
}; | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
OpenApiTypeChecker.isReference = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isReference(schema); | ||
}; | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
OpenApiTypeChecker.isOneOf = function (schema) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isOneOf(schema); | ||
}; | ||
/** | ||
* Test whether the schema is recursive reference type. | ||
* | ||
* Test whether the target schema is a reference type, and test one thign more | ||
* that the reference is self-recursive or not. | ||
* | ||
* @param props Properties for recursive reference test | ||
* @returns Whether the schema is recursive reference type or not | ||
*/ | ||
OpenApiTypeChecker.isRecursiveReference = function (props) { | ||
@@ -69,11 +157,67 @@ return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.isRecursiveReference({ | ||
----------------------------------------------------------- */ | ||
/** | ||
* Escape from the {@link OpenApi.IJsonSchema.IReference} type. | ||
* | ||
* Escape from the {@link OpenApi.IJsonSchema.IReference} type, replacing the | ||
* every references to the actual schemas. If the escape is successfull, the returned | ||
* schema never contains any {@link OpenApi.IJsonSchema.IReference} type in its | ||
* structure. | ||
* | ||
* If the schema has a recursive reference, the recursive reference would be repeated | ||
* as much as the `props.recursive` depth. If you've configured the `props.recursive` | ||
* as `false` or `0`, it would be failed and return an {@link IOpenApiSchemaError}. | ||
* Also, if there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find | ||
* the matched type in the {@link OpenApi.IComponents.schemas}, it would also be failed | ||
* and return an {@link IOpenApiSchemaError} either. | ||
* | ||
* @param props Properties for escaping | ||
* @returns Escaped schema, or error with reason | ||
*/ | ||
OpenApiTypeChecker.escape = function (props) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.escape(__assign(__assign({}, props), { prefix: "#/components/schemas/", method: "OpenApiTypeChecker.method" })); | ||
}; | ||
/** | ||
* Unreference the schema. | ||
* | ||
* Unreference the schema, replacing the {@link OpenApi.IJsonSchema.IReference} type | ||
* to the actual schema. Different with {@link escape} is, the `unreference` function | ||
* does not resolve every references in the schema, but resolve only one time. | ||
* | ||
* If there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find | ||
* the matched type in the {@link OpenApi.IComponents.schemas}, and you've called this | ||
* `unreference()` function with the reference, it would also be failed and return an | ||
* {@link IOpenApiSchemaError} value. | ||
* | ||
* @param props Properties of unreference | ||
* @returns Unreferenced schema | ||
*/ | ||
OpenApiTypeChecker.unreference = function (props) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.unreference(__assign(__assign({}, props), { prefix: "#/components/schemas/", method: "OpenApiTypeChecker.unreference" })); | ||
}; | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link OpenApi.IJsonSchema.IOneOf.oneOf} | ||
* - {@link OpenApi.IJsonSchema.IReference} | ||
* - {@link OpenApi.IJsonSchema.IObject.properties} | ||
* - {@link OpenApi.IJsonSchema.IObject.additionalProperties} | ||
* - {@link OpenApi.IJsonSchema.IArray.items} | ||
* - {@link OpenApi.IJsonSchema.ITuple.prefixItems} | ||
* - {@link OpenApi.IJsonSchema.ITuple.additionalItems} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
OpenApiTypeChecker.visit = function (props) { | ||
return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.visit(__assign(__assign({}, props), { prefix: "#/components/schemas/" })); | ||
}; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
OpenApiTypeChecker.covers = function (props) { | ||
@@ -80,0 +224,0 @@ return OpenApiTypeCheckerBase_1.OpenApiTypeCheckerBase.covers({ |
{ | ||
"name": "@samchon/openapi", | ||
"version": "2.0.0-dev.20241202-2", | ||
"version": "2.0.0", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -1,7 +0,1 @@ | ||
> ## Next version is coming. | ||
> | ||
> This is the `next` version README document. | ||
> | ||
> If you wanna see the latest version, go to the [`v1.0` branch](https://github.com/samchon/openapi/tree/v1.0). | ||
# `@samchon/openapi` | ||
@@ -21,3 +15,3 @@ ```mermaid | ||
lfc --"Google"--> gemini("Gemini") | ||
lfc --"Meta (Facebook)"--> llama("Llama") | ||
lfc --"Meta"--> llama("Llama") | ||
end | ||
@@ -27,3 +21,3 @@ ``` | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/openapi/blob/master/LICENSE) | ||
[![npm version](https://img.shields.io/npm/v/@samchon/openapi/next.svg)](https://www.npmjs.com/package/@samchon/openapi/next.svg) | ||
[![npm version](https://img.shields.io/npm/v/@samchon/openapi.svg)](https://www.npmjs.com/package/@samchon/openapi.svg) | ||
[![Downloads](https://img.shields.io/npm/dm/@samchon/openapi.svg)](https://www.npmjs.com/package/@samchon/openapi) | ||
@@ -60,6 +54,6 @@ [![Build Status](https://github.com/samchon/openapi/workflows/build/badge.svg)](https://github.com/samchon/openapi/actions?query=workflow%3Abuild) | ||
```bash | ||
npm install @samchon/openapi --tag next | ||
npm install @samchon/openapi | ||
``` | ||
Just install by `npm i @samchon/openapi --tag next` command. | ||
Just install by `npm i @samchon/openapi` command. | ||
@@ -219,3 +213,3 @@ Here is an example code utilizing the `@samchon/openapi` for LLM function calling purpose. | ||
lfc --"Google"--> gemini("Gemini") | ||
lfc --"Meta (Facebook)"--> llama("Llama") | ||
lfc --"Meta"--> llama("Llama") | ||
end | ||
@@ -238,5 +232,5 @@ ``` | ||
- [`IChatGptSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IChatGptSchema.ts): OpenAI ChatGPT | ||
- [`IClaudeSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IClaudeSchema.ts): Anthropic Claude (same with [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts)) | ||
- [`IClaudeSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IClaudeSchema.ts): Anthropic Claude | ||
- [`IGeminiSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IGeminiSchema.ts): Google Gemini | ||
- [`ILlamaSchema`](https://github.com/samchon/openapi/blob/master/src/structures/ILlamaSchema.ts): Meta (Facebook) Llama (same with [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts)) | ||
- [`ILlamaSchema`](https://github.com/samchon/openapi/blob/master/src/structures/ILlamaSchema.ts): Meta Llama | ||
- [`ILlmSchemaV3`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3.ts): middle layer based on OpenAPI v3.0 specification | ||
@@ -243,0 +237,0 @@ - [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts): middle layer based on OpenAPI v3.1 specification |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { IChatGptSchema } from "../structures/IChatGptSchema"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { IHttpMigrateRoute } from "../../structures/IHttpMigrateRoute"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import type { HttpLlm } from "../HttpLlm"; |
@@ -0,0 +0,0 @@ import { HttpMigration } from "./HttpMigration"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "./OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApiV3 } from "./OpenApiV3"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; |
@@ -0,0 +0,0 @@ /// <reference lib="dom" /> |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; |
@@ -0,0 +0,0 @@ import { IGeminiSchema } from "./IGeminiSchema"; |
@@ -0,0 +0,0 @@ import { ILlmSchema } from "./ILlmSchema"; |
@@ -0,0 +0,0 @@ import { IChatGptSchema } from "./IChatGptSchema"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
import { OpenApi } from "../OpenApi"; | ||
/** | ||
* OpenAPI schema related error. | ||
* | ||
* `IOpenApiSchemaError` is a type representing an error that occured during the | ||
* iteration or transformation of the OpenAPI schema (JSON schema) of | ||
* {@link OpenApi.IJsonSchema} type. | ||
* | ||
* The most `IOpenApiSchemaError` is occured by the transformation process from | ||
* {@link OpenApi.IJsonSchema} to {@link ILlmSchema} type. The transformation can | ||
* be failed by following reasons: | ||
* | ||
* - Unable to find the {@link OpenApi.IJsonSchema.IReference} directing. | ||
* - Non-supported type in LLM schema models | ||
* - Every models do not support {@link OpenApi.IJsonSchema.ITuple} | ||
* - Gemini does not support {@link OpenApi.IJsonSchema.IOneOf} | ||
* - ChatGPT and Gemini do not support {@link OpenApi.IJsonSchema.IObject.additionalProperties} | ||
* | ||
* @author Jeongho Nam - https://github.com/samchon | ||
*/ | ||
export interface IOpenApiSchemaError { | ||
/** | ||
* Method that caused the error. | ||
*/ | ||
method: string; | ||
/** | ||
* Message of the error. | ||
*/ | ||
message: string; | ||
/** | ||
* The detailed reasons of the error. | ||
*/ | ||
reasons: IOpenApiSchemaError.IReason[]; | ||
} | ||
export namespace IOpenApiSchemaError { | ||
/** | ||
* Detailed reason of the error. | ||
*/ | ||
export interface IReason { | ||
/** | ||
* Schema that caused the error. | ||
*/ | ||
schema: OpenApi.IJsonSchema; | ||
/** | ||
* Accessor to the schema. | ||
*/ | ||
accessor: string; | ||
/** | ||
* Message of the reason. | ||
*/ | ||
message: string; | ||
} | ||
} |
@@ -0,11 +1,46 @@ | ||
/** | ||
* Result of an operation that can either succeed or fail. | ||
* | ||
* `IResult` is an union type that represents the result of an operation | ||
* that can either succeed or fail. | ||
* | ||
* You can distinguise the result by checking the {@link IResult.success} value, | ||
* and if it's `true`, the success value is stored in {@link IResult.value}. | ||
* Otherwise, if it's `false`, the error value is stored in {@link IResult.error}. | ||
* | ||
* @template T Type of the success value. | ||
* @template E Type of the error value. | ||
* @author Jeongho Nam - https://github.com/samchon | ||
*/ | ||
export type IResult<T, E> = IResult.ISuccess<T> | IResult.IFailure<E>; | ||
export namespace IResult { | ||
/** | ||
* Success type of {@link IResult}. | ||
*/ | ||
export interface ISuccess<T> { | ||
/** | ||
* Success flag. | ||
*/ | ||
success: true; | ||
/** | ||
* Success value. | ||
*/ | ||
value: T; | ||
} | ||
/** | ||
* Failure type of {@link IResult}. | ||
*/ | ||
export interface IFailure<E> { | ||
/** | ||
* Success flag. | ||
*/ | ||
success: false; | ||
/** | ||
* The error value. | ||
*/ | ||
error: E; | ||
} | ||
} |
@@ -0,0 +0,0 @@ export namespace AccessorUtil { |
@@ -8,2 +8,8 @@ import { IChatGptSchema } from "../structures/IChatGptSchema"; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
export const isNull = ( | ||
@@ -14,2 +20,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
export const isUnknown = ( | ||
@@ -22,2 +34,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
export const isBoolean = ( | ||
@@ -28,2 +46,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
export const isInteger = ( | ||
@@ -34,2 +58,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
export const isNumber = ( | ||
@@ -40,2 +70,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
export const isString = ( | ||
@@ -46,2 +82,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
export const isArray = ( | ||
@@ -53,2 +95,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
export const isObject = ( | ||
@@ -59,2 +107,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
export const isReference = ( | ||
@@ -64,2 +118,8 @@ schema: IChatGptSchema, | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
export const isAnyOf = ( | ||
@@ -73,2 +133,16 @@ schema: IChatGptSchema, | ||
----------------------------------------------------------- */ | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link IChatGptSchema.IAnyOf.anyOf} | ||
* - {@link IChatGptSchema.IReference} | ||
* - {@link IChatGptSchema.IObject.properties} | ||
* - {@link IChatGptSchema.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
export const visit = (props: { | ||
@@ -102,2 +176,8 @@ closure: (schema: IChatGptSchema, accessor: string) => void; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
export const covers = (props: { | ||
@@ -104,0 +184,0 @@ $defs?: Record<string, IChatGptSchema> | undefined; |
@@ -14,2 +14,14 @@ import { IGeminiSchema } from "../structures/IGeminiSchema"; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link IGeminiSchema.IObject.properties} | ||
* - {@link IGeminiSchema.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
export const visit = (props: { | ||
@@ -38,2 +50,8 @@ closure: (schema: IGeminiSchema, accessor: string) => void; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
export const covers = (x: IGeminiSchema, y: IGeminiSchema): boolean => { | ||
@@ -134,2 +152,8 @@ // CHECK EQUALITY | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
export const isBoolean = ( | ||
@@ -140,2 +164,8 @@ schema: IGeminiSchema, | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
export const isInteger = ( | ||
@@ -146,2 +176,8 @@ schema: IGeminiSchema, | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
export const isNumber = ( | ||
@@ -152,2 +188,8 @@ schema: IGeminiSchema, | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
export const isString = ( | ||
@@ -158,2 +200,8 @@ schema: IGeminiSchema, | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
export const isArray = ( | ||
@@ -164,2 +212,8 @@ schema: IGeminiSchema, | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
export const isObject = ( | ||
@@ -170,2 +224,8 @@ schema: IGeminiSchema, | ||
/** | ||
* Test whether the schema is a null type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
export const isNullOnly = ( | ||
@@ -176,2 +236,17 @@ schema: IGeminiSchema, | ||
/** | ||
* Test whether the schema is a nullable type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether nullable type or not | ||
*/ | ||
export const isNullable = (schema: IGeminiSchema): boolean => | ||
!isUnknown(schema) && (isNullOnly(schema) || schema.nullable === true); | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
export const isUnknown = ( | ||
@@ -178,0 +253,0 @@ schema: IGeminiSchema, |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { ILlmFunction } from "../structures/ILlmFunction"; |
@@ -8,2 +8,8 @@ import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1"; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
export const isNull = ( | ||
@@ -13,2 +19,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
export const isUnknown = ( | ||
@@ -19,2 +31,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is a constant type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether constant type or not | ||
*/ | ||
export const isConstant = ( | ||
@@ -25,2 +43,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
export const isBoolean = ( | ||
@@ -31,2 +55,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
export const isInteger = ( | ||
@@ -37,2 +67,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
export const isNumber = ( | ||
@@ -43,2 +79,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
export const isString = ( | ||
@@ -49,2 +91,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
export const isArray = ( | ||
@@ -54,2 +102,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
export const isObject = ( | ||
@@ -60,2 +114,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
export const isReference = ( | ||
@@ -66,2 +126,8 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
export const isOneOf = ( | ||
@@ -71,2 +137,11 @@ schema: ILlmSchemaV3_1, | ||
/** | ||
* Test whether the schema is recursive reference type. | ||
* | ||
* Test whether the target schema is a reference type, and test one thign more | ||
* that the reference is self-recursive or not. | ||
* | ||
* @param props Properties for recursive reference test | ||
* @returns Whether the schema is recursive reference type or not | ||
*/ | ||
export const isRecursiveReference = (props: { | ||
@@ -87,2 +162,8 @@ $defs?: Record<string, ILlmSchemaV3_1>; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
export const covers = (props: { | ||
@@ -102,2 +183,17 @@ $defs?: Record<string, ILlmSchemaV3_1>; | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link ILlmSchemaV3_1.IOneOf.oneOf} | ||
* - {@link ILlmSchemaV3_1.IReference} | ||
* - {@link ILlmSchemaV3_1.IObject.properties} | ||
* - {@link ILlmSchemaV3_1.IObject.additionalProperties} | ||
* - {@link ILlmSchemaV3_1.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
export const visit = (props: { | ||
@@ -104,0 +200,0 @@ closure: (schema: ILlmSchemaV3_1, accessor: string) => void; |
@@ -17,11 +17,11 @@ import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3"; | ||
* | ||
* Visit every nested schemas of the target, and apply the callback function | ||
* to them. | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* If the visitor meets an union type, it will visit every individual schemas | ||
* in the union type. Otherwise meets an object type, it will visit every | ||
* properties and additional properties. If the visitor meets an array type, | ||
* it will visit the item type. | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* @param props Target and callback function | ||
* - {@link ILlmSchemaV3.IOneOf.oneOf} | ||
* - {@link ILlmSchemaV3.IObject.additionalProperties} | ||
* - {@link ILlmSchemaV3.IArray.items} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
@@ -28,0 +28,0 @@ export const visit = (props: { |
@@ -6,2 +6,9 @@ import { OpenApi } from "../OpenApi"; | ||
/** | ||
* Type checker of OpenAPI type schema. | ||
* | ||
* `OpenApiTypeChecker` is a type checker of {@link OpenApi.IJsonSchema}. | ||
* | ||
* @author Jeongho Nam - https://github.com/samchon | ||
*/ | ||
export namespace OpenApiTypeChecker { | ||
@@ -11,2 +18,8 @@ /* ----------------------------------------------------------- | ||
----------------------------------------------------------- */ | ||
/** | ||
* Test whether the schema is a nul type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether null type or not | ||
*/ | ||
export const isNull = ( | ||
@@ -17,2 +30,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is an unknown type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether unknown type or not | ||
*/ | ||
export const isUnknown = ( | ||
@@ -23,2 +42,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is a constant type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether constant type or not | ||
*/ | ||
export const isConstant = ( | ||
@@ -29,2 +54,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is a boolean type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether boolean type or not | ||
*/ | ||
export const isBoolean = ( | ||
@@ -35,2 +66,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is an integer type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether integer type or not | ||
*/ | ||
export const isInteger = ( | ||
@@ -41,2 +78,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is a number type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether number type or not | ||
*/ | ||
export const isNumber = ( | ||
@@ -47,2 +90,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is a string type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether string type or not | ||
*/ | ||
export const isString = ( | ||
@@ -53,2 +102,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is an array type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether array type or not | ||
*/ | ||
export const isArray = ( | ||
@@ -59,2 +114,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is a tuple type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether tuple type or not | ||
*/ | ||
export const isTuple = ( | ||
@@ -65,2 +126,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is an object type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether object type or not | ||
*/ | ||
export const isObject = ( | ||
@@ -71,2 +138,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is a reference type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether reference type or not | ||
*/ | ||
export const isReference = ( | ||
@@ -77,2 +150,8 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is an union type. | ||
* | ||
* @param schema Target schema | ||
* @returns Whether union type or not | ||
*/ | ||
export const isOneOf = ( | ||
@@ -83,2 +162,11 @@ schema: OpenApi.IJsonSchema, | ||
/** | ||
* Test whether the schema is recursive reference type. | ||
* | ||
* Test whether the target schema is a reference type, and test one thign more | ||
* that the reference is self-recursive or not. | ||
* | ||
* @param props Properties for recursive reference test | ||
* @returns Whether the schema is recursive reference type or not | ||
*/ | ||
export const isRecursiveReference = (props: { | ||
@@ -97,2 +185,20 @@ components: OpenApi.IComponents; | ||
----------------------------------------------------------- */ | ||
/** | ||
* Escape from the {@link OpenApi.IJsonSchema.IReference} type. | ||
* | ||
* Escape from the {@link OpenApi.IJsonSchema.IReference} type, replacing the | ||
* every references to the actual schemas. If the escape is successfull, the returned | ||
* schema never contains any {@link OpenApi.IJsonSchema.IReference} type in its | ||
* structure. | ||
* | ||
* If the schema has a recursive reference, the recursive reference would be repeated | ||
* as much as the `props.recursive` depth. If you've configured the `props.recursive` | ||
* as `false` or `0`, it would be failed and return an {@link IOpenApiSchemaError}. | ||
* Also, if there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find | ||
* the matched type in the {@link OpenApi.IComponents.schemas}, it would also be failed | ||
* and return an {@link IOpenApiSchemaError} either. | ||
* | ||
* @param props Properties for escaping | ||
* @returns Escaped schema, or error with reason | ||
*/ | ||
export const escape = (props: { | ||
@@ -111,2 +217,17 @@ components: OpenApi.IComponents; | ||
/** | ||
* Unreference the schema. | ||
* | ||
* Unreference the schema, replacing the {@link OpenApi.IJsonSchema.IReference} type | ||
* to the actual schema. Different with {@link escape} is, the `unreference` function | ||
* does not resolve every references in the schema, but resolve only one time. | ||
* | ||
* If there's a {@link OpenApi.IJsonSchema.IReference} type which cannot find | ||
* the matched type in the {@link OpenApi.IComponents.schemas}, and you've called this | ||
* `unreference()` function with the reference, it would also be failed and return an | ||
* {@link IOpenApiSchemaError} value. | ||
* | ||
* @param props Properties of unreference | ||
* @returns Unreferenced schema | ||
*/ | ||
export const unreference = (props: { | ||
@@ -124,2 +245,19 @@ components: OpenApi.IComponents; | ||
/** | ||
* Visit every nested schemas. | ||
* | ||
* Visit every nested schemas of the target, and apply the `props.closure` function. | ||
* | ||
* Here is the list of occuring nested visitings: | ||
* | ||
* - {@link OpenApi.IJsonSchema.IOneOf.oneOf} | ||
* - {@link OpenApi.IJsonSchema.IReference} | ||
* - {@link OpenApi.IJsonSchema.IObject.properties} | ||
* - {@link OpenApi.IJsonSchema.IObject.additionalProperties} | ||
* - {@link OpenApi.IJsonSchema.IArray.items} | ||
* - {@link OpenApi.IJsonSchema.ITuple.prefixItems} | ||
* - {@link OpenApi.IJsonSchema.ITuple.additionalItems} | ||
* | ||
* @param props Properties for visiting | ||
*/ | ||
export const visit = (props: { | ||
@@ -137,2 +275,8 @@ closure: (schema: OpenApi.IJsonSchema, accessor: string) => void; | ||
/** | ||
* Test whether the `x` schema covers the `y` schema. | ||
* | ||
* @param props Properties for testing | ||
* @returns Whether the `x` schema covers the `y` schema | ||
*/ | ||
export const covers = (props: { | ||
@@ -139,0 +283,0 @@ components: OpenApi.IComponents; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1714035
30480
0
493
146
64
146