api

api package overview

npm package: @forge-ts/api

Installation

npm install @forge-ts/api

Description

The api package.

Key Concepts

The pipeline runs in four steps: createWalker traverses the project AST; extractSDKTypes selects symbols relevant to the public SDK surface; generateOpenAPISpec converts those types to an OpenAPI 3.2 document (including path items derived from @route tags and schemas from signatureToSchema); generateApi writes the result to config.api.openapiPath. The buildReference helper produces a flat ReferenceEntry[] for use in rendered API reference pages. Key exports: - generateApi — Run the full walk → extract → generate → write pipeline. - generateOpenAPISpec — Build an OpenAPIDocument from config and SDK types. - extractSDKTypes — Select public SDK types from the symbol graph. - buildReference — Produce a flat API reference entry list. - signatureToSchema — Map a TypeScript type signature to a JSON Schema object. - OpenAPIDocument — The generated OpenAPI 3.2 document structure. - OpenAPISchemaObject — A JSON Schema object as used inside the spec. - SDKType / SDKProperty — Intermediate SDK type extraction types. - ReferenceEntry — One entry in the structured API reference catalogue.

Quick Usage

import { loadConfig } from "@forge-ts/core";
import { generateApi } from "@forge-ts/api";

const config = await loadConfig();
const result = await generateApi(config);
console.log(result.success); // true if the spec was written successfully

Functions & Classes

SymbolKindDescription
signatureToSchema()functionMaps a TypeScript type signature string to an OpenAPI 3.2 schema object. Han...
extractSDKTypes()functionExtracts SDK-relevant types (interfaces, type aliases, classes, enums) from a...
generateOpenAPISpec()functionGenerates a production-quality OpenAPI 3.2 document from the extracted SDK ty...
buildReference()functionBuilds a structured API reference from a list of exported symbols. Unlike th...
generateApi()functionRuns the API generation pipeline: walk → extract → generate → write.
signatureToSchema()functionMaps a TypeScript type signature string to an OpenAPI 3.2 schema object. Han...
extractSDKTypes()functionExtracts SDK-relevant types (interfaces, type aliases, classes, enums) from a...
generateOpenAPISpec()functionGenerates a production-quality OpenAPI 3.2 document from the extracted SDK ty...
buildReference()functionBuilds a structured API reference from a list of exported symbols. Unlike th...
generateApi()functionRuns the API generation pipeline: walk → extract → generate → write.

Types & Interfaces

SymbolKindDescription
SDKPropertyinterfaceA single property extracted from an interface or class symbol.
SDKTypeinterfaceAn SDK type descriptor extracted from the symbol graph.
ReferenceEntryinterfaceA single entry in the generated API reference.
SDKPropertyinterfaceA single property extracted from an interface or class symbol.
SDKTypeinterfaceAn SDK type descriptor extracted from the symbol graph.
ReferenceEntryinterfaceA single entry in the generated API reference.

Other Exports

SymbolKindDescription
tsup.config.tsfile
schema-mapper.tsfile
sdk-extractor.tsfile
openapi.tsfile
reference.tsfile
index.tsfileOpenAPI 3.2 spec generator and structured API reference builder for forge-ts....
api.test.tsfile
schema-mapper.tsfile
sdk-extractor.tsfile
openapi.tsfile
reference.tsfile
index.tsfileforge-ts/api — OpenAPI spec and API reference generator. Extracts public SDK...
api.test.tsfile

On this page