Skip to main content
Version: v8.0.0

OpenapiRequestGenerator


Import
import { OpenapiRequestGenerator } from "@hyper-fetch/cli"

Parameters

class OpenapiRequestGenerator {
constructor(openapiDocument: any) {};
generateFile(__namedParameters: { config: { aliases: { api: string; components: string; hooks: string; lib: string; ui: string }; resolvedPaths: { api: string; components: string; cwd: string; hooks: string; lib: string; ui: string }; tsx: boolean }; fileName: string }) => Promise<string>;
generateRequestsFromSchema() => Promise<{ createSdkFn: string; generatedTypes: string[]; schemaTypes: string; sdkSchema: string }>;
generateHyperFetchRequest(__namedParameters: { id: string; method: string; path: string; queryParamsRequired?: boolean }, types: Record<string, string>) => string;
generateMethodMetadata(operation: { method: string; operationId: string; path: string } & Partial<Operation>, exportTypes: ExportedType[]) => { errorType: string; id: string; method: string; path: string; pathParametersType: undefined | string; queryParametersType: undefined | string; queryParamsRequired: boolean; requestBodyType: undefined | string; responseType: string };
generateRequestInstanceType(__namedParameters: { id: string; path: string; queryParamsRequired?: boolean }, types: Record<string, string>) => string;
generateTypes(__namedParameters: { errorType: string; id: string; pathParametersType: undefined | string; queryParametersType: undefined | string; requestBodyType: undefined | string; responseType: string }) => GeneratedTypes<string>;
getSchemaFromUrl(__namedParameters: { config: { aliases: { api: string; components: string; hooks: string; lib: string; ui: string }; resolvedPaths: { api: string; components: string; cwd: string; hooks: string; lib: string; ui: string }; tsx: boolean }; url: string }) => Promise<any>;
prepareSchema(openapiDocument: Document) => Promise<{ exportedTypes: ExportedType[]; schemaTypes: string }>;
validateSchema(openapiDocument: Document) => void;
}
Parameters
NameTypeDescription
openapiDocument
any

Methods

validateSchema()

Preview
validateSchema(openapiDocument: Document)
Parameters
Parameters
NameTypeDescription
openapiDocument
Document
Returns
void

prepareSchema()

Preview
prepareSchema(openapiDocument: Document)
Parameters
Parameters
NameTypeDescription
openapiDocument
Document
Returns
Promise<{ exportedTypes: ExportedType[]; schemaTypes: string }>

getSchemaFromUrl()

Preview
getSchemaFromUrl(__namedParameters: { config: { aliases: { api: string; components: string; hooks: string; lib: string; ui: string }; resolvedPaths: { api: string; components: string; cwd: string; hooks: string; lib: string; ui: string }; tsx: boolean }; url: string })
Parameters
Parameters
NameTypeDescription
__namedParameters
{ config: { aliases: { api: string; components: string; hooks: string; lib: string; ui: string }; resolvedPaths: { api: string; components: string; cwd: string; hooks: string; lib: string; ui: string }; tsx: boolean }; url: string }
Returns
Promise<any>

generateTypes()

Preview
generateTypes(__namedParameters: { errorType: string; id: string; pathParametersType: undefined | string; queryParametersType: undefined | string; requestBodyType: undefined | string; responseType: string })
Parameters
Parameters
NameTypeDescription
__namedParameters
{ errorType: string; id: string; pathParametersType: undefined | string; queryParametersType: undefined | string; requestBodyType: undefined | string; responseType: string }
Returns
GeneratedTypes<string>

generateRequestInstanceType()

Preview
generateRequestInstanceType(__namedParameters: { id: string; path: string; queryParamsRequired?: boolean }, types: Record<string, string>)
Parameters
Parameters
NameTypeDescription
__namedParameters
{ id: string; path: string; queryParamsRequired?: boolean }
types
Record<string, string>
Returns
string

generateMethodMetadata()

Preview
generateMethodMetadata(operation: { method: string; operationId: string; path: string } & Partial<Operation>, exportTypes: ExportedType[])
Parameters
Parameters
NameTypeDescription
operation
{ method: string; operationId: string; path: string } & Partial<Operation>
exportTypes
ExportedType[]
Returns
generateMethodMetadata
NameTypeDescription
errorType
string
id
string
method
string
path
string
pathParametersType
undefined | string
queryParametersType
undefined | string
queryParamsRequired
boolean
requestBodyType
undefined | string
responseType
string

generateHyperFetchRequest()

Preview
generateHyperFetchRequest(__namedParameters: { id: string; method: string; path: string; queryParamsRequired?: boolean }, types: Record<string, string>)
Parameters
Parameters
NameTypeDescription
__namedParameters
{ id: string; method: string; path: string; queryParamsRequired?: boolean }
types
Record<string, string>
Returns
string

generateRequestsFromSchema()

Preview
generateRequestsFromSchema()
Returns
Promise<{ createSdkFn: string; generatedTypes: string[]; schemaTypes: string; sdkSchema: string }>

generateFile()

Preview
generateFile(__namedParameters: { config: { aliases: { api: string; components: string; hooks: string; lib: string; ui: string }; resolvedPaths: { api: string; components: string; cwd: string; hooks: string; lib: string; ui: string }; tsx: boolean }; fileName: string })
Parameters
Parameters
NameTypeDescription
__namedParameters
{ config: { aliases: { api: string; components: string; hooks: string; lib: string; ui: string }; resolvedPaths: { api: string; components: string; cwd: string; hooks: string; lib: string; ui: string }; tsx: boolean }; fileName: string }
Returns
Promise<string>