@kubb/plugin-oas
Version:
OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.
293 lines (292 loc) • 5.63 kB
TypeScript
import { t as __name } from "./chunk--u3MIqq1.js";
import { SchemaObject } from "@kubb/oas";
import { KubbFile } from "@kubb/fabric-core/types";
//#region src/SchemaMapper.d.ts
type SchemaKeywordMapper = {
object: {
keyword: 'object';
args: {
properties: {
[x: string]: Schema[];
};
additionalProperties: Schema[];
patternProperties?: Record<string, Schema[]>;
strict?: boolean;
};
};
url: {
keyword: 'url';
};
readOnly: {
keyword: 'readOnly';
};
writeOnly: {
keyword: 'writeOnly';
};
uuid: {
keyword: 'uuid';
};
email: {
keyword: 'email';
};
firstName: {
keyword: 'firstName';
};
lastName: {
keyword: 'lastName';
};
phone: {
keyword: 'phone';
};
password: {
keyword: 'password';
};
date: {
keyword: 'date';
args: {
type?: 'date' | 'string';
};
};
time: {
keyword: 'time';
args: {
type?: 'date' | 'string';
};
};
datetime: {
keyword: 'datetime';
args: {
offset?: boolean;
local?: boolean;
};
};
tuple: {
keyword: 'tuple';
args: {
items: Schema[];
min?: number;
max?: number;
rest?: Schema;
};
};
array: {
keyword: 'array';
args: {
items: Schema[];
min?: number;
max?: number;
unique?: boolean;
};
};
enum: {
keyword: 'enum';
args: {
name: string;
typeName: string;
asConst: boolean;
items: Array<{
name: string | number;
format: 'string' | 'number' | 'boolean';
value?: string | number | boolean;
}>;
};
};
and: {
keyword: 'and';
args: Schema[];
};
const: {
keyword: 'const';
args: {
name: string | number;
format: 'string' | 'number' | 'boolean';
value?: string | number | boolean;
};
};
union: {
keyword: 'union';
args: Schema[];
};
ref: {
keyword: 'ref';
args: {
name: string;
$ref: string;
/**
* Full qualified path.
*/
path: KubbFile.Path;
/**
* When true `File.Import` is used.
* When false a reference is used inside the current file.
*/
isImportable: boolean;
};
};
matches: {
keyword: 'matches';
args?: string;
};
boolean: {
keyword: 'boolean';
};
default: {
keyword: 'default';
args: string | number | boolean;
};
string: {
keyword: 'string';
};
integer: {
keyword: 'integer';
};
bigint: {
keyword: 'bigint';
};
number: {
keyword: 'number';
};
max: {
keyword: 'max';
args: number;
};
min: {
keyword: 'min';
args: number;
};
exclusiveMaximum: {
keyword: 'exclusiveMaximum';
args: number;
};
exclusiveMinimum: {
keyword: 'exclusiveMinimum';
args: number;
};
describe: {
keyword: 'describe';
args: string;
};
example: {
keyword: 'example';
args: string;
};
deprecated: {
keyword: 'deprecated';
};
optional: {
keyword: 'optional';
};
undefined: {
keyword: 'undefined';
};
nullish: {
keyword: 'nullish';
};
nullable: {
keyword: 'nullable';
};
null: {
keyword: 'null';
};
any: {
keyword: 'any';
};
unknown: {
keyword: 'unknown';
};
void: {
keyword: 'void';
};
blob: {
keyword: 'blob';
};
schema: {
keyword: 'schema';
args: {
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
format?: string;
};
};
name: {
keyword: 'name';
args: string;
};
catchall: {
keyword: 'catchall';
};
interface: {
keyword: 'interface';
};
};
declare const schemaKeywords: {
any: "any";
unknown: "unknown";
number: "number";
integer: "integer";
bigint: "bigint";
string: "string";
boolean: "boolean";
undefined: "undefined";
nullable: "nullable";
null: "null";
nullish: "nullish";
array: "array";
tuple: "tuple";
enum: "enum";
union: "union";
datetime: "datetime";
date: "date";
email: "email";
uuid: "uuid";
url: "url";
void: "void";
default: "default";
const: "const";
and: "and";
describe: "describe";
min: "min";
max: "max";
exclusiveMinimum: "exclusiveMinimum";
exclusiveMaximum: "exclusiveMaximum";
optional: "optional";
readOnly: "readOnly";
writeOnly: "writeOnly";
object: "object";
ref: "ref";
matches: "matches";
firstName: "firstName";
lastName: "lastName";
password: "password";
phone: "phone";
blob: "blob";
deprecated: "deprecated";
example: "example";
schema: "schema";
catchall: "catchall";
time: "time";
name: "name";
interface: "interface";
};
type SchemaKeyword = keyof SchemaKeywordMapper;
type SchemaMapper<T = string | null | undefined> = { [K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined };
type SchemaKeywordBase<T> = {
keyword: SchemaKeyword;
args: T;
};
type Schema = {
keyword: string;
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
type SchemaTree = {
schema: SchemaObject;
parent: Schema | undefined;
current: Schema;
siblings: Schema[];
/**
* this is equal to the key of a property(object)
*/
name?: string;
};
declare function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]>;
//#endregion
export { SchemaMapper as a, schemaKeywords as c, SchemaKeywordMapper as i, SchemaKeyword as n, SchemaTree as o, SchemaKeywordBase as r, isKeyword as s, Schema as t };
//# sourceMappingURL=SchemaMapper-SneuY1wg.d.ts.map