UNPKG

api

Version:

Magical SDK generation from an OpenAPI definition 🪄

64 lines • 2.47 kB
import type Storage from '../storage.js'; import type { InstallerOptions } from './factory.js'; import type Oas from 'oas'; export default abstract class CodeGenerator { /** The associated API definition */ spec: Oas; /** * The path to the API definion (might be a local path, a URL, or an API registry identifier) * @example https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore-simple.json * @example @petstore/v1.0#n6kvf10vakpemvplx * @example ./petstore.json */ specPath: string; /** * The user-specified identifier for the SDK, * used as the directory name in the `.api/apis` directory * where the SDK source code is located. */ identifier: string; /** The user agent which is set for all outgoing fetch requests */ userAgent: string; /** * The license associated with the SDK. * This is extrapolated from the API definition file. */ spdxLicense?: string; /** * Contact info for the API and/or SDK author in case users need support. * This is extrapolated from the API definition file. */ apiContact: { name?: string; url?: string; }; /** * An object containing any downstream packages that are required * for building/executing the SDK. */ requiredPackages: Record<string, { dependencyType: 'development' | 'production'; reason: string; url?: string; version: string; }>; /** * An example code snippet that a user can run to get started with the SDK. */ exampleCodeSnippet?: string | false; constructor(spec: Oas, specPath: string, identifier: string); abstract generate(): Promise<Record<string, string>>; abstract install(storage: Storage, opts?: InstallerOptions): Promise<void>; /** * It would be better if this were an abstract function but TS/JS doesn't have support for that so * we instead have to rely on throwing a `TypeError` if it's not been implemented instead of a * build-time error. * * @see {@link https://github.com/microsoft/TypeScript/issues/34516} */ static uninstall(storage: Storage, opts?: InstallerOptions): Promise<void>; abstract compile(storage: Storage, opts?: InstallerOptions): Promise<void>; abstract getExampleCodeSnippet(): Promise<string | false>; hasRequiredPackages(): boolean; } //# sourceMappingURL=codegenerator.d.ts.map