UNPKG

@infinite-debugger/swagger-to-ts

Version:

swagger-to-ts is a powerful library that allows you to generate TypeScript code from Swagger documentation or OpenAPI specifications. It simplifies the process of integrating API definitions into your TypeScript projects, saving you time and effort.

47 lines (46 loc) 2.32 kB
import '@infinite-debugger/rmk-js-extensions/String'; import { z } from 'zod'; import { OpenAPISpecification } from '../models'; import { GenerateModelMappingsOptions } from './ModelCodeGenerator'; import { GenerateTSEDControllersCodeConfigurationOptions } from './TSEDControllersCodeGenerator'; export declare const RequestOperationNameSourceValidationSchema: z.ZodEnum<["requestSummary", "requestOperationId"]>; export type RequestOperationNameSource = z.infer<typeof RequestOperationNameSourceValidationSchema>; export interface GenerateTypescriptAPIOptions extends Pick<GenerateModelMappingsOptions, 'inferTypeFromValidationSchema'>, Pick<GenerateTSEDControllersCodeConfigurationOptions, 'tsedControllerNamePrefix' | 'tsedControllerNameSuffix'> { /** * The OpenAPI specification to generate the Typescript API from. */ openAPISpecification: OpenAPISpecification; /** * The root path to output the generated Typescript API to. */ outputRootPath: string; /** * Whether to output the internal state of the Typescript API generator. */ outputInternalState?: boolean; /** * The source to use for the operation name of each request. */ requestOperationNameSource?: RequestOperationNameSource; /** * Whether to generate TSED controllers. */ generateTsEDControllers?: boolean; /** * The import path to use for the Ts.ED `Authenticate` decorator. */ tsEDAuthenticateDecoratorImportPath?: string; /** * The import path to use for the Ts.ED `Authorize` decorator. */ tsEDAuthorizeDecoratorImportPath?: string; /** * Whether to propagate request headers from TsEd controller methods to the API function calls. */ propagateRequestHeaders?: boolean; /** * The scope name to use for the generated Typescript API. */ scopeName?: string; } export declare const generateTypescriptAPI: ({ openAPISpecification: inputOpenAPISpecification, outputRootPath, outputInternalState, generateTsEDControllers, requestOperationNameSource, inferTypeFromValidationSchema, tsEDAuthenticateDecoratorImportPath, tsEDAuthorizeDecoratorImportPath, tsedControllerNamePrefix, tsedControllerNameSuffix, propagateRequestHeaders, scopeName, }: GenerateTypescriptAPIOptions) => Promise<void>;