OpenapiRequestGenerator
Import
import { OpenapiRequestGenerator } from "@hyper-fetch/cli"
Source
Package
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
| Name | Type | Description |
|---|---|---|
| openapiDocument | |
Methods
validateSchema()
Source
Preview
validateSchema(openapiDocument: Document)
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| openapiDocument | |
Returns
void
prepareSchema()
Source
Preview
prepareSchema(openapiDocument: Document)
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| openapiDocument | |
Returns
Promise<{ exportedTypes: ExportedType[]; schemaTypes: string }>
getSchemaFromUrl()
Source
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
| Name | Type | Description |
|---|---|---|
| __namedParameters | |
Returns
Promise<any>
generateTypes()
Source
Preview
generateTypes(__namedParameters: { errorType: string; id: string; pathParametersType: undefined | string; queryParametersType: undefined | string; requestBodyType: undefined | string; responseType: string })
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| __namedParameters | |
Returns
GeneratedTypes<string>
generateRequestInstanceType()
Source
Preview
generateRequestInstanceType(__namedParameters: { id: string; path: string; queryParamsRequired?: boolean }, types: Record<string, string>)
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| __namedParameters | | |
| types | |
Returns
string
generateMethodMetadata()
Source
Preview
generateMethodMetadata(operation: { method: string; operationId: string; path: string } & Partial<Operation>, exportTypes: ExportedType[])
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| operation | | |
| exportTypes | |
Returns
generateMethodMetadata
| Name | Type | Description |
|---|---|---|
| errorType | | |
| id | | |
| method | | |
| path | | |
| pathParametersType | | |
| queryParametersType | | |
| queryParamsRequired | | |
| requestBodyType | | |
| responseType | |
generateHyperFetchRequest()
Source
Preview
generateHyperFetchRequest(__namedParameters: { id: string; method: string; path: string; queryParamsRequired?: boolean }, types: Record<string, string>)
Parameters
Parameters
| Name | Type | Description |
|---|---|---|
| __namedParameters | | |
| types | |
Returns
string
generateRequestsFromSchema()
Source
Preview
generateRequestsFromSchema()
Returns
Promise<{ createSdkFn: string; generatedTypes: string[]; schemaTypes: string; sdkSchema: string }>
generateFile()
Source
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
| Name | Type | Description |
|---|---|---|
| __namedParameters | |
Returns
Promise<string>
