oazapfts
Version:
OpenApi TypeScript client generator
1,077 lines (924 loc) • 37.1 kB
TypeScript
import { AsyncSeriesBailHook } from 'tapable';
import { AsyncSeriesHook } from 'tapable';
import { AsyncSeriesWaterfallHook } from 'tapable';
import { ContentType } from './mimeTypes';
import { CustomHeaders } from '@oazapfts/runtime';
import { default as default_2 } from 'typescript';
import { InterfaceDeclaration } from 'typescript';
import { OpenAPIV3 } from 'openapi-types';
import { OpenAPIV3_1 } from 'openapi-types';
import { Statement } from 'typescript';
import { SyncWaterfallHook } from 'tapable';
import { TypeAliasDeclaration } from 'typescript';
import { TypeReferenceNode } from 'typescript';
declare type ArgumentStyle = (typeof argumentStyleOptions)[number];
declare type ArgumentStyle_2 = (typeof argumentStyleOptions_2)[number];
declare const argumentStyleOptions: readonly ["positional", "object"];
declare const argumentStyleOptions_2: readonly ["positional", "object"];
/**
* Create a call expression for one of the oazapfts runtime functions.
*/
declare function callOazapftsFunction(name: string, args: default_2.Expression[], typeArgs?: default_2.TypeNode[]): default_2.CallExpression;
/**
* Create a call expression for one of the QS runtime functions.
*/
declare function callQsFunction(name: string, args: default_2.Expression[]): default_2.CallExpression;
/**
* Checks if readOnly/writeOnly properties are present in the given schema.
* Returns a tuple of booleans; the first one is about readOnly, the second
* one is about writeOnly.
*/
declare function checkSchemaOnlyMode(schema: SchemaObject_3 | ReferenceObject, ctx: OazapftsContext, resolveRefs?: boolean): OnlyModes;
declare type ContentType_2 = "json" | "form" | "multipart";
declare const contentTypes: Record<string, ContentType_2>;
/** Creates: export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = { ... }; */
export declare function createDefaultsStatement(defaults: Defaults): default_2.VariableStatement;
/**
* Convert an Import definition to a TypeScript ImportDeclaration AST node.
*
* Supported formats:
* - string: side-effect import `import "module";`
* - [specifiers[], { from }]: named imports `import { a, b } from "module";`
* - [default, { from }]: default import `import X from "module";`
* - [default, specifiers[], { from }]: default + named `import X, { a } from "module";`
* - [{ namespace }, { from }]: namespace import `import * as X from "module";`
*/
export declare function createImportStatement(imp: Import): default_2.ImportDeclaration;
export declare function createServersStatement(servers: ServerObject_3[]): default_2.VariableStatement;
/**
* Create a template string literal from the given OpenAPI urlTemplate.
* Curly braces in the path are turned into identifier expressions,
* which are read from the local scope during runtime.
*/
declare function createUrlExpression(path: string, qs?: default_2.Expression): default_2.StringLiteral | default_2.TemplateExpression;
declare type DefaultImport = [string, {
from: string;
}];
declare type DefaultImport_2 = [string, {
from: string;
}];
declare type DefaultImport_2_2 = [string, {
from: string;
}];
declare type DefaultImport_3 = [string, {
from: string;
}];
declare type Defaults = {
baseUrl?: string;
headers?: CustomHeaders;
FormData?: default_2.ClassExpression | default_2.Identifier;
fetch?: default_2.FunctionExpression | default_2.ArrowFunction | default_2.Identifier;
};
declare type Defaults_2 = {
baseUrl?: string;
headers?: CustomHeaders;
FormData?: default_2.ClassExpression | default_2.Identifier;
fetch?: default_2.FunctionExpression | default_2.ArrowFunction | default_2.Identifier;
};
declare type Defaults_2_2 = {
baseUrl?: string;
headers?: CustomHeaders;
FormData?: default_2.ClassExpression | default_2.Identifier;
fetch?: default_2.FunctionExpression | default_2.ArrowFunction | default_2.Identifier;
};
declare type Defaults_3 = {
baseUrl?: string;
headers?: CustomHeaders;
FormData?: default_2.ClassExpression | default_2.Identifier;
fetch?: default_2.FunctionExpression | default_2.ArrowFunction | default_2.Identifier;
};
declare type DiscriminatorObject = OpenAPIV3.DiscriminatorObject | OpenAPIV3_1.DiscriminatorObject;
declare type Document_2 = OpenAPIV3.Document | OpenAPIV3_1.Document;
declare type Document_2_2 = OpenAPIV3.Document | OpenAPIV3_1.Document;
declare type Document_2_3 = OpenAPIV3.Document | OpenAPIV3_1.Document;
declare type Document_3 = OpenAPIV3.Document | OpenAPIV3_1.Document;
declare type Document_3_2 = OpenAPIV3.Document | OpenAPIV3_1.Document;
declare type EnumStyle = (typeof enumStyleOptions)[number];
declare type EnumStyle_2 = (typeof enumStyleOptions_2)[number];
declare type EnumStyle_3 = (typeof enumStyleOptions_3)[number];
declare const enumStyleOptions: readonly ["union", "enum", "as-const"];
declare const enumStyleOptions_2: readonly ["union", "enum", "as-const"];
declare const enumStyleOptions_3: readonly ["union", "enum", "as-const"];
declare function findAvailableRef(ref: string, ctx: OazapftsContext): string;
export declare function generateApi(ctx: OazapftsContext, hooks: UNSTABLE_OazapftsPluginHooks_2): Promise<default_2.SourceFile>;
export declare function generateClientMethod(method: h.HttpMethod, path: string, operation: OpenApi.OperationObject, pathItem: OpenApi.PathItemObject, ctx: OazapftsContext, hooks: UNSTABLE_OazapftsPluginHooks_2): default_2.Statement[];
declare function getBodyFormatter(body?: RequestBodyObject): ContentType | undefined;
/**
* Extract custom member names from `x-enumNames` or `x-enum-varnames` extensions.
* Returns `undefined` when neither extension is present.
*/
declare function getCustomNames(schema: Exclude<SchemaObject_3, boolean>, values: unknown[]): string[] | undefined;
/**
* Resolve the effective enum style from options.
* `enumStyle` takes precedence over the deprecated `useEnumType`.
*/
declare function getEnumStyle(opts: {
enumStyle?: EnumStyle_3;
useEnumType?: boolean;
}): EnumStyle_3;
/**
* Return a unique alias for an enum declaration.
* Reuses the existing name when the same enum values have already been registered.
*/
declare function getEnumUniqueAlias(name: string, values: string, ctx: OazapftsContext): string;
/**
* Get the name of a formatter function for a given parameter.
*/
declare function getFormatter({ style, explode, content, }: ParameterObject): "json" | "form" | "deep" | "explode" | "space" | "pipe";
/**
* Create a method name for a given operation, either from its operationId or
* the HTTP verb and path.
*/
export declare function getOperationName(verb: string, path: string, operationId?: string, operationNames?: Map<string, number>,
/** @deprecated will be removed in next major version */
DEPRECATED_legacyName?: true): string;
/**
* Create method name(s) for a given operation, either from its operationId or
* the HTTP verb and path. Returns the primary name and optionally a deprecated
* legacy name for backward compatibility.
*
* @deprecated will be removed in next major version. Use `getOperationName` instead
*/
export declare function getOperationNames(verb: string, path: string, operationId?: string, operationNames?: Map<string, number>): OperationNames;
/**
* Create a type alias for the schema referenced by the given ReferenceObject
*/
export declare function getRefAlias(obj: OpenApi.ReferenceObject, ctx: OazapftsContext, ignoreDiscriminator?: boolean): default_2.TypeNode;
export declare function getResponseType(ctx: OazapftsContext, responses?: ResponsesObject): "json" | "text" | "blob";
export declare function getSchemaFromContent(content: Record<string, OpenApi.MediaTypeObject>): OpenApi.SchemaObject | OpenApi.ReferenceObject;
export declare function getTypeFromResponse(resOrRef: OpenApi.ResponseObject | OpenApi.ReferenceObject, ctx: OazapftsContext): default_2.TypeNode;
export declare function getTypeFromResponses(responses: OpenApi.ResponsesObject, ctx: OazapftsContext): default_2.UnionTypeNode;
/**
* Creates a type node from a given schema.
* Delegates to getBaseTypeFromSchema internally and
* optionally adds a union with null.
*/
export declare function getTypeFromSchema(ctx: OazapftsContext, schema?: OpenApi.SchemaObject | OpenApi.ReferenceObject, name?: string): default_2.TypeNode;
declare function getUniqueAlias(name: string, ctx: OazapftsContext): string;
declare namespace h {
export {
supportDeepObjects,
toIdentifier,
getFormatter,
callQsFunction,
createUrlExpression,
callOazapftsFunction,
getBodyFormatter,
wrapResult,
findAvailableRef,
isNamedEnumSchema,
getEnumStyle,
enumStyleOptions_3 as enumStyleOptions,
EnumStyle_3 as EnumStyle,
getEnumUniqueAlias,
getCustomNames,
getUniqueAlias,
checkSchemaOnlyMode,
isMimeType,
isJsonMimeType,
ContentType_2 as ContentType,
contentTypes,
isNullable,
isHttpMethod,
HttpMethod_3 as HttpMethod
}
}
declare type HttpMethod = (typeof HttpMethods)[number];
declare type HttpMethod_2 = (typeof HttpMethods_2)[number];
declare type HttpMethod_2_2 = (typeof HttpMethods_2_2)[number];
declare type HttpMethod_3 = (typeof HttpMethods_3)[number];
declare const HttpMethods: readonly ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
declare const HttpMethods_2: readonly ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
declare const HttpMethods_2_2: readonly ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
declare const HttpMethods_3: readonly ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
declare type Import = string | ImportsWithoutDefault | DefaultImport | ImportWithDefault | NamespaceImport;
declare type Import_2 = string | ImportsWithoutDefault_2 | DefaultImport_2 | ImportWithDefault_2 | NamespaceImport_2;
declare type Import_2_2 = string | ImportsWithoutDefault_2_2 | DefaultImport_2_2 | ImportWithDefault_2_2 | NamespaceImport_2_2;
declare type Import_3 = string | ImportsWithoutDefault_3 | DefaultImport_3 | ImportWithDefault_3 | NamespaceImport_3;
declare type ImportSpecifier = {
name: string;
as?: string;
};
declare type ImportSpecifier_2 = {
name: string;
as?: string;
};
declare type ImportSpecifier_2_2 = {
name: string;
as?: string;
};
declare type ImportSpecifier_3 = {
name: string;
as?: string;
};
declare type ImportsWithoutDefault = [
(ImportSpecifier | string)[],
{
from: string;
}
];
declare type ImportsWithoutDefault_2 = [
(ImportSpecifier_2 | string)[],
{
from: string;
}
];
declare type ImportsWithoutDefault_2_2 = [
(ImportSpecifier_2_2 | string)[],
{
from: string;
}
];
declare type ImportsWithoutDefault_3 = [
(ImportSpecifier_3 | string)[],
{
from: string;
}
];
declare type ImportWithDefault = [
string,
(ImportSpecifier | string)[],
{
from: string;
}
];
declare type ImportWithDefault_2 = [
string,
(ImportSpecifier_2 | string)[],
{
from: string;
}
];
declare type ImportWithDefault_2_2 = [
string,
(ImportSpecifier_2_2 | string)[],
{
from: string;
}
];
declare type ImportWithDefault_3 = [
string,
(ImportSpecifier_3 | string)[],
{
from: string;
}
];
declare function isHttpMethod(method: string): method is HttpMethod_3;
declare function isJsonMimeType(mime: string): boolean;
declare function isMimeType(s: unknown): boolean;
/**
* Check if a schema is suitable for generating a named enum declaration
* (has enum values, has a name, and is not a boolean type).
*/
declare function isNamedEnumSchema(schema: SchemaObject_3, name?: string): name is string;
declare function isNullable(schema?: SchemaObject_3 | ReferenceObject): boolean | undefined;
declare type MediaTypeObject = OpenAPIV3.MediaTypeObject | OpenAPIV3_1.MediaTypeObject;
declare type NamespaceImport = [{
namespace: string;
}, {
from: string;
}];
declare type NamespaceImport_2 = [{
namespace: string;
}, {
from: string;
}];
declare type NamespaceImport_2_2 = [{
namespace: string;
}, {
from: string;
}];
declare type NamespaceImport_3 = [{
namespace: string;
}, {
from: string;
}];
declare type OazapftsContext = {
readonly opts: ReadonlyDeep<OazapftsOptions>;
readonly spec: Document_2;
readonly mode?: OnlyMode;
/** Banner comment at the top of the file (the text content, not including comment markers) */
banner: string;
/** Import declarations (AST nodes) */
imports: Import[];
/** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */
defaults: Defaults;
/** Server definitions - will be generated as `export const servers = { ... }` */
servers: ServerObject_2[];
/** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */
init: Statement[];
discriminatingSchemas: Set<SchemaObject_2>;
aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];
enumAliases: Statement[];
enumRefs: Record<string, {
values: string;
type: TypeReferenceNode;
}>;
refs: Record<string, {
base: TypeReferenceNode;
readOnly?: TypeReferenceNode;
writeOnly?: TypeReferenceNode;
}>;
refsOnlyMode: Map<string, OnlyModes>;
typeAliases: Record<string, number>;
operationNames: Map<string, number>;
};
declare type OazapftsContext_2 = {
readonly opts: ReadonlyDeep_2<OazapftsOptions>;
readonly spec: Document_2_2;
readonly mode?: OnlyMode_2;
/** Banner comment at the top of the file (the text content, not including comment markers) */
banner: string;
/** Import declarations (AST nodes) */
imports: Import_2[];
/** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */
defaults: Defaults_2;
/** Server definitions - will be generated as `export const servers = { ... }` */
servers: ServerObject[];
/** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */
init: Statement[];
discriminatingSchemas: Set<SchemaObject>;
aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];
enumAliases: Statement[];
enumRefs: Record<string, {
values: string;
type: TypeReferenceNode;
}>;
refs: Record<string, {
base: TypeReferenceNode;
readOnly?: TypeReferenceNode;
writeOnly?: TypeReferenceNode;
}>;
refsOnlyMode: Map<string, OnlyModes_2>;
typeAliases: Record<string, number>;
operationNames: Map<string, number>;
};
declare type OazapftsContext_2_2 = {
readonly opts: ReadonlyDeep_2_2<OazapftsOptions_2>;
readonly spec: Document_2_3;
readonly mode?: OnlyMode_3;
/** Banner comment at the top of the file (the text content, not including comment markers) */
banner: string;
/** Import declarations (AST nodes) */
imports: Import_3[];
/** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */
defaults: Defaults_3;
/** Server definitions - will be generated as `export const servers = { ... }` */
servers: ServerObject_4[];
/** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */
init: Statement[];
discriminatingSchemas: Set<SchemaObject_4>;
aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];
enumAliases: Statement[];
enumRefs: Record<string, {
values: string;
type: TypeReferenceNode;
}>;
refs: Record<string, {
base: TypeReferenceNode;
readOnly?: TypeReferenceNode;
writeOnly?: TypeReferenceNode;
}>;
refsOnlyMode: Map<string, OnlyModes_3>;
typeAliases: Record<string, number>;
operationNames: Map<string, number>;
};
declare type OazapftsContext_3 = {
readonly opts: ReadonlyDeep_3<OazapftsOptions_2>;
readonly spec: Document_3_2;
readonly mode?: OnlyMode_2_2;
/** Banner comment at the top of the file (the text content, not including comment markers) */
banner: string;
/** Import declarations (AST nodes) */
imports: Import_2_2[];
/** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */
defaults: Defaults_2_2;
/** Server definitions - will be generated as `export const servers = { ... }` */
servers: ServerObject_2_2[];
/** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */
init: Statement[];
discriminatingSchemas: Set<SchemaObject_2_2>;
aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];
enumAliases: Statement[];
enumRefs: Record<string, {
values: string;
type: TypeReferenceNode;
}>;
refs: Record<string, {
base: TypeReferenceNode;
readOnly?: TypeReferenceNode;
writeOnly?: TypeReferenceNode;
}>;
refsOnlyMode: Map<string, OnlyModes_2_2>;
typeAliases: Record<string, number>;
operationNames: Map<string, number>;
};
declare type OazapftsOptions = {
include?: string[];
exclude?: string[];
optimistic?: boolean;
unionUndefined?: boolean;
/**
* @deprecated Use `enumStyle: "enum"` instead.
*/
useEnumType?: boolean;
/**
* Controls how enums are generated in TypeScript.
* Takes precedence over `useEnumType` if both are specified.
*/
enumStyle?: EnumStyle;
mergeReadWriteOnly?: boolean;
useUnknown?: boolean;
argumentStyle?: ArgumentStyle;
allSchemas?: boolean;
/**
* When true, serialize boolean query parameters as 1/0.
*/
numericBooleanQueryParameters?: boolean;
/**
* When true, skip generating deprecated legacy method aliases for backward
* compatibility. Only the primary normalized operationId-based names will
* be generated.
*/
futureStripLegacyMethods?: boolean;
/**
* Plugins to apply during code generation.
* Each plugin receives hooks and can tap into generation steps.
*/
UNSTABLE_plugins?: UNSTABLE_OazapftsPlugin[];
};
declare type OazapftsOptions_2 = {
include?: string[];
exclude?: string[];
optimistic?: boolean;
unionUndefined?: boolean;
/**
* @deprecated Use `enumStyle: "enum"` instead.
*/
useEnumType?: boolean;
/**
* Controls how enums are generated in TypeScript.
* Takes precedence over `useEnumType` if both are specified.
*/
enumStyle?: EnumStyle_2;
mergeReadWriteOnly?: boolean;
useUnknown?: boolean;
argumentStyle?: ArgumentStyle_2;
allSchemas?: boolean;
/**
* When true, serialize boolean query parameters as 1/0.
*/
numericBooleanQueryParameters?: boolean;
/**
* When true, skip generating deprecated legacy method aliases for backward
* compatibility. Only the primary normalized operationId-based names will
* be generated.
*/
futureStripLegacyMethods?: boolean;
/**
* Plugins to apply during code generation.
* Each plugin receives hooks and can tap into generation steps.
*/
UNSTABLE_plugins?: UNSTABLE_OazapftsPlugin_2[];
};
declare type OnlyMode = "readOnly" | "writeOnly";
declare type OnlyMode_2 = "readOnly" | "writeOnly";
declare type OnlyMode_2_2 = "readOnly" | "writeOnly";
declare type OnlyMode_3 = "readOnly" | "writeOnly";
declare type OnlyModes = Record<OnlyMode, boolean>;
declare type OnlyModes_2 = Record<OnlyMode_2, boolean>;
declare type OnlyModes_2_2 = Record<OnlyMode_2_2, boolean>;
declare type OnlyModes_3 = Record<OnlyMode_3, boolean>;
declare namespace OpenAPI {
{
SchemaObject,
UNSTABLE_DiscriminatingSchemaObject,
ReferenceObject,
ParameterObject,
Document_2 as Document,
DiscriminatorObject,
ResponseObject,
ResponsesObject,
RequestBodyObject,
MediaTypeObject,
OperationObject,
PathsObject,
PathItemObject,
ServerObject
}
}
declare namespace OpenApi {
export {
SchemaObject_3 as SchemaObject,
UNSTABLE_DiscriminatingSchemaObject,
ReferenceObject,
ParameterObject,
Document_3 as Document,
DiscriminatorObject,
ResponseObject,
ResponsesObject,
RequestBodyObject,
MediaTypeObject,
OperationObject,
PathsObject,
PathItemObject,
ServerObject_3 as ServerObject
}
}
declare namespace OpenAPI_2 {
{
SchemaObject,
UNSTABLE_DiscriminatingSchemaObject,
ReferenceObject,
ParameterObject,
Document_2 as Document,
DiscriminatorObject,
ResponseObject,
ResponsesObject,
RequestBodyObject,
MediaTypeObject,
OperationObject,
PathsObject,
PathItemObject,
ServerObject
}
}
declare namespace OpenApi_2 {
{
SchemaObject_2 as SchemaObject,
UNSTABLE_DiscriminatingSchemaObject,
ReferenceObject,
ParameterObject,
Document_3 as Document,
DiscriminatorObject,
ResponseObject,
ResponsesObject,
RequestBodyObject,
MediaTypeObject,
OperationObject,
PathsObject,
PathItemObject,
ServerObject_2 as ServerObject
}
}
/**
* Result of getOperationNames containing the primary method name and
* optionally a deprecated legacy name for backward compatibility.
*/
declare type OperationNames = {
primaryName: string;
/**
* When set, indicates the legacy fallback name that older versions of
* oazapfts would have generated. A deprecated alias should be emitted.
*/
deprecatedLegacyName?: string;
};
declare type OperationObject = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject;
declare type ParameterObject = OpenAPIV3.ParameterObject | OpenAPIV3_1.ParameterObject;
declare type PathItemObject = OpenAPIV3.PathItemObject | OpenAPIV3_1.PathItemObject;
declare type PathsObject = OpenAPIV3.PathsObject | OpenAPIV3_1.PathsObject;
/**
* In order to support discriminated unions.
*
* @see https://github.com/oazapfts/oazapfts/pull/473
*
* Does three things:
* 1. Add a `x-component-ref-path` property.
* 2. Record discriminating schemas in `this.discriminatingSchemas`. A discriminating schema
* refers to a schema that has a `discriminator` property which is neither used in conjunction
* with `oneOf` nor `anyOf`.
* 3. Make all mappings of discriminating schemas explicit to generate types immediately.
*/
export declare function preprocessComponents(ctx: OazapftsContext): void;
declare type ReadonlyDeep<T> = {
readonly [P in keyof T]: ReadonlyDeep<T[P]>;
};
declare type ReadonlyDeep_2<T> = {
readonly [P in keyof T]: ReadonlyDeep_2<T[P]>;
};
declare type ReadonlyDeep_2_2<T> = {
readonly [P in keyof T]: ReadonlyDeep_2_2<T[P]>;
};
declare type ReadonlyDeep_3<T> = {
readonly [P in keyof T]: ReadonlyDeep_3<T[P]>;
};
declare type ReferenceObject = OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject;
declare type RequestBodyObject = OpenAPIV3.RequestBodyObject | OpenAPIV3_1.RequestBodyObject;
declare type ResponseObject = OpenAPIV3.ResponseObject | OpenAPIV3_1.ResponseObject;
declare type ResponsesObject = OpenAPIV3.ResponsesObject | OpenAPIV3_1.ResponsesObject;
declare type SchemaObject = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | boolean;
declare type SchemaObject_2 = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | boolean;
declare type SchemaObject_2_2 = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | boolean;
declare type SchemaObject_3 = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | boolean;
declare type SchemaObject_4 = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | boolean;
declare type ServerObject = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
declare type ServerObject_2 = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
declare type ServerObject_2_2 = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
declare type ServerObject_3 = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
declare type ServerObject_4 = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
/**
* @deprecated This is actually no longer used as with 7.0
* (https://github.com/oazapfts/oazapfts/blob/0749939947f5bae60842322254cd109dfbee053b/packages/codegen/src/generate.ts#L1430C35-L1432)
* This had only been applied to converted specs that are no longer handled
* by oazapfts. Keeping this as a reminder in the codebase for now.
* Could be moved in a swagger plugin that handles the conversion from Swagger to OpenAPI.
*
* Despite its name, OpenApi's `deepObject` serialization does not support
* deeply nested objects. As a workaround we detect parameters that contain
* square brackets and merge them into a single object.
*/
declare function supportDeepObjects(params: ParameterObject[]): OpenAPIV3[];
declare function toIdentifier(s: string, upper?: boolean, onlyMode?: OnlyMode): string;
declare type UNSTABLE_ComposeSourceHookArgs = [OazapftsContext_2, default_2.Statement[]];
declare type UNSTABLE_ComposeSourceHookArgs_2 = [OazapftsContext_2_2, default_2.Statement[]];
declare type UNSTABLE_ComposeSourceHookArgs_3 = [OazapftsContext_3, default_2.Statement[]];
declare type UNSTABLE_DiscriminatingSchemaObject = Exclude<SchemaObject_3, boolean> & {
discriminator: NonNullable<Exclude<SchemaObject_3, boolean>["discriminator"]>;
};
declare type UNSTABLE_EndpointHookArgs = [
{
method: HttpMethod;
path: string;
operation: OpenAPI.OperationObject;
pathItem: OpenAPI.PathItemObject;
},
OazapftsContext_2
];
declare type UNSTABLE_EndpointHookArgs_2 = [
{
method: HttpMethod_2;
path: string;
operation: OpenAPI_2.OperationObject;
pathItem: OpenAPI_2.PathItemObject;
},
OazapftsContext_2_2
];
declare type UNSTABLE_EndpointHookArgs_3 = [
{
method: HttpMethod_2_2;
path: string;
operation: OpenApi_2.OperationObject;
pathItem: OpenApi_2.PathItemObject;
},
OazapftsContext_3
];
declare enum UNSTABLE_OAZAPFTS_PLUGIN_PRECEDENCE {
EAGER = "eager",
DEFAULT = "default",
LAZY = "lazy"
}
declare enum UNSTABLE_OAZAPFTS_PLUGIN_PRECEDENCE_2 {
EAGER = "eager",
DEFAULT = "default",
LAZY = "lazy"
}
declare type UNSTABLE_OazapftsPlugin = UNSTABLE_OazapftsPluginFn & UNSTABLE_OazapftsPluginOptions;
declare type UNSTABLE_OazapftsPlugin_2 = UNSTABLE_OazapftsPluginFn_2 & UNSTABLE_OazapftsPluginOptions_2;
/**
* A plugin initiator function that receives hooks and can tap into them.
*/
declare type UNSTABLE_OazapftsPluginFn = (hooks: UNSTABLE_OazapftsPluginHooks) => void | Promise<void>;
/**
* A plugin initiator function that receives hooks and can tap into them.
*/
declare type UNSTABLE_OazapftsPluginFn_2 = (hooks: UNSTABLE_OazapftsPluginHooks_2_2) => void | Promise<void>;
declare type UNSTABLE_OazapftsPluginHooks = {
/**
* Called after context is created with all template parts initialized.
* Use this to modify the spec, context, or template parts.
* This is the only hook where ctx.spec is mutable.
*/
prepare: AsyncSeriesHook<[OazapftsContext_2]>;
/**
* Decide whether a given endpoint should be generated.
* Receives the current decision (default true) as first argument.
* Return false to skip endpoint generation.
*/
filterEndpoint: SyncWaterfallHook<[
boolean,
{
method: HttpMethod;
path: string;
operation: OpenAPI.OperationObject;
pathItem: OpenAPI.PathItemObject;
},
OazapftsContext_2
]>;
/**
* Generate client methods for an endpoint.
* This is a bail hook: the first plugin that returns a value wins.
* Return `undefined` to delegate to later plugins.
*/
generateMethod: AsyncSeriesBailHook<UNSTABLE_EndpointHookArgs, default_2.Statement[] | undefined>;
/**
* Refine client methods for an endpoint.
* Receives generated methods and can return a modified array.
* Runs after generateMethod for each endpoint.
*/
refineMethod: AsyncSeriesWaterfallHook<[
default_2.Statement[],
...UNSTABLE_EndpointHookArgs
]>;
/**
* Compose top-level source statements from context and generated methods.
* This is a bail hook: the first plugin that returns a value wins.
* Return `undefined` to delegate to later plugins.
*/
composeSource: AsyncSeriesBailHook<UNSTABLE_ComposeSourceHookArgs, default_2.Statement[] | undefined>;
/**
* Refine top-level source statements before SourceFile construction.
* Receives composed statements and can return a modified array.
* Runs after composeSource.
*/
refineSource: AsyncSeriesWaterfallHook<[
default_2.Statement[],
...UNSTABLE_ComposeSourceHookArgs
]>;
/**
* Customize query serializer call arguments for each formatter call.
* Default behavior is identity (returns the original args unchanged).
*/
querySerializerArgs: SyncWaterfallHook<UNSTABLE_QuerySerializerHookArgs>;
/**
* Called after the full AST has been generated, before printing to string.
* Use this to add/modify/remove statements from the final source file.
*/
astGenerated: AsyncSeriesWaterfallHook<[default_2.SourceFile, OazapftsContext_2]>;
};
declare type UNSTABLE_OazapftsPluginHooks_2 = {
/**
* Called after context is created with all template parts initialized.
* Use this to modify the spec, context, or template parts.
* This is the only hook where ctx.spec is mutable.
*/
prepare: AsyncSeriesHook<[OazapftsContext_3]>;
/**
* Decide whether a given endpoint should be generated.
* Receives the current decision (default true) as first argument.
* Return false to skip endpoint generation.
*/
filterEndpoint: SyncWaterfallHook<[
boolean,
{
method: HttpMethod_2_2;
path: string;
operation: OpenApi_2.OperationObject;
pathItem: OpenApi_2.PathItemObject;
},
OazapftsContext_3
]>;
/**
* Generate client methods for an endpoint.
* This is a bail hook: the first plugin that returns a value wins.
* Return `undefined` to delegate to later plugins.
*/
generateMethod: AsyncSeriesBailHook<UNSTABLE_EndpointHookArgs_3, default_2.Statement[] | undefined>;
/**
* Refine client methods for an endpoint.
* Receives generated methods and can return a modified array.
* Runs after generateMethod for each endpoint.
*/
refineMethod: AsyncSeriesWaterfallHook<[
default_2.Statement[],
...UNSTABLE_EndpointHookArgs_3
]>;
/**
* Compose top-level source statements from context and generated methods.
* This is a bail hook: the first plugin that returns a value wins.
* Return `undefined` to delegate to later plugins.
*/
composeSource: AsyncSeriesBailHook<UNSTABLE_ComposeSourceHookArgs_3, default_2.Statement[] | undefined>;
/**
* Refine top-level source statements before SourceFile construction.
* Receives composed statements and can return a modified array.
* Runs after composeSource.
*/
refineSource: AsyncSeriesWaterfallHook<[
default_2.Statement[],
...UNSTABLE_ComposeSourceHookArgs_3
]>;
/**
* Customize query serializer call arguments for each formatter call.
* Default behavior is identity (returns the original args unchanged).
*/
querySerializerArgs: SyncWaterfallHook<UNSTABLE_QuerySerializerHookArgs_3>;
/**
* Called after the full AST has been generated, before printing to string.
* Use this to add/modify/remove statements from the final source file.
*/
astGenerated: AsyncSeriesWaterfallHook<[default_2.SourceFile, OazapftsContext_3]>;
};
declare type UNSTABLE_OazapftsPluginHooks_2_2 = {
/**
* Called after context is created with all template parts initialized.
* Use this to modify the spec, context, or template parts.
* This is the only hook where ctx.spec is mutable.
*/
prepare: AsyncSeriesHook<[OazapftsContext_2_2]>;
/**
* Decide whether a given endpoint should be generated.
* Receives the current decision (default true) as first argument.
* Return false to skip endpoint generation.
*/
filterEndpoint: SyncWaterfallHook<[
boolean,
{
method: HttpMethod_2;
path: string;
operation: OpenAPI_2.OperationObject;
pathItem: OpenAPI_2.PathItemObject;
},
OazapftsContext_2_2
]>;
/**
* Generate client methods for an endpoint.
* This is a bail hook: the first plugin that returns a value wins.
* Return `undefined` to delegate to later plugins.
*/
generateMethod: AsyncSeriesBailHook<UNSTABLE_EndpointHookArgs_2, default_2.Statement[] | undefined>;
/**
* Refine client methods for an endpoint.
* Receives generated methods and can return a modified array.
* Runs after generateMethod for each endpoint.
*/
refineMethod: AsyncSeriesWaterfallHook<[
default_2.Statement[],
...UNSTABLE_EndpointHookArgs_2
]>;
/**
* Compose top-level source statements from context and generated methods.
* This is a bail hook: the first plugin that returns a value wins.
* Return `undefined` to delegate to later plugins.
*/
composeSource: AsyncSeriesBailHook<UNSTABLE_ComposeSourceHookArgs_2, default_2.Statement[] | undefined>;
/**
* Refine top-level source statements before SourceFile construction.
* Receives composed statements and can return a modified array.
* Runs after composeSource.
*/
refineSource: AsyncSeriesWaterfallHook<[
default_2.Statement[],
...UNSTABLE_ComposeSourceHookArgs_2
]>;
/**
* Customize query serializer call arguments for each formatter call.
* Default behavior is identity (returns the original args unchanged).
*/
querySerializerArgs: SyncWaterfallHook<UNSTABLE_QuerySerializerHookArgs_2>;
/**
* Called after the full AST has been generated, before printing to string.
* Use this to add/modify/remove statements from the final source file.
*/
astGenerated: AsyncSeriesWaterfallHook<[default_2.SourceFile, OazapftsContext_2_2]>;
};
declare type UNSTABLE_OazapftsPluginOptions = {
name?: string;
version?: string;
precedence?: UNSTABLE_OAZAPFTS_PLUGIN_PRECEDENCE;
};
declare type UNSTABLE_OazapftsPluginOptions_2 = {
name?: string;
version?: string;
precedence?: UNSTABLE_OAZAPFTS_PLUGIN_PRECEDENCE_2;
};
declare type UNSTABLE_QuerySerializerHookArgs = [
default_2.Expression[],
{
method: HttpMethod;
path: string;
operation: OpenAPI.OperationObject;
pathItem: OpenAPI.PathItemObject;
formatter: string;
parameters: OpenAPI.ParameterObject[];
query: OpenAPI.ParameterObject[];
},
OazapftsContext_2
];
declare type UNSTABLE_QuerySerializerHookArgs_2 = [
default_2.Expression[],
{
method: HttpMethod_2;
path: string;
operation: OpenAPI_2.OperationObject;
pathItem: OpenAPI_2.PathItemObject;
formatter: string;
parameters: OpenAPI_2.ParameterObject[];
query: OpenAPI_2.ParameterObject[];
},
OazapftsContext_2_2
];
declare type UNSTABLE_QuerySerializerHookArgs_3 = [
default_2.Expression[],
{
method: HttpMethod_2_2;
path: string;
operation: OpenApi_2.OperationObject;
pathItem: OpenApi_2.PathItemObject;
formatter: string;
parameters: OpenApi_2.ParameterObject[];
query: OpenApi_2.ParameterObject[];
},
OazapftsContext_3
];
declare function wrapResult(ex: default_2.Expression, ctx: OazapftsContext): default_2.Expression;
export { }