UNPKG

@spec2ts/openapi-client

Version:

Utility to convert OpenAPI v3 specifications to Typescript HTTP client using TypeScript native compiler

25 lines (24 loc) 1.11 kB
import * as ts from "typescript"; import type { PathItemObject, OperationObject, ParameterObject } from "openapi3-ts/oas31"; import { ParserContext } from "@spec2ts/jsonschema/lib/core-parser"; import type { OApiGeneratorOptions } from "./openapi-generator"; export type Method = "GET" | "PUT" | "POST" | "DELETE" | "OPTIONS" | "HEAD" | "PATCH" | "TRACE"; export type ContentTypeMode = "json" | "form" | "multipart"; export interface OApiGeneratorContext extends ParserContext { options: OApiGeneratorOptions; typesFile?: ts.SourceFile; } export interface ParsedOperation { name: string; paramsVars: Record<string, string>; args: ts.ParameterDeclaration[]; query: ParameterObject[]; header: ParameterObject[]; response: ts.TypeNode; responseJSON?: boolean; responseVoid?: boolean; bodyMode?: ContentTypeMode; bodyVar?: string; } export declare function parseOperation(path: string, item: PathItemObject, method: Method, operation: OperationObject, context: OApiGeneratorContext): ParsedOperation; export declare function isMethod(method: string): method is Method;