api
api package overview
npm package: @forge-ts/api
Installation
npm install @forge-ts/apiDescription
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 successfullyFunctions & Classes
| Symbol | Kind | Description |
|---|---|---|
signatureToSchema() | function | Maps a TypeScript type signature string to an OpenAPI 3.2 schema object. Han... |
extractSDKTypes() | function | Extracts SDK-relevant types (interfaces, type aliases, classes, enums) from a... |
generateOpenAPISpec() | function | Generates a production-quality OpenAPI 3.2 document from the extracted SDK ty... |
buildReference() | function | Builds a structured API reference from a list of exported symbols. Unlike th... |
generateApi() | function | Runs the API generation pipeline: walk → extract → generate → write. |
signatureToSchema() | function | Maps a TypeScript type signature string to an OpenAPI 3.2 schema object. Han... |
extractSDKTypes() | function | Extracts SDK-relevant types (interfaces, type aliases, classes, enums) from a... |
generateOpenAPISpec() | function | Generates a production-quality OpenAPI 3.2 document from the extracted SDK ty... |
buildReference() | function | Builds a structured API reference from a list of exported symbols. Unlike th... |
generateApi() | function | Runs the API generation pipeline: walk → extract → generate → write. |
Types & Interfaces
| Symbol | Kind | Description |
|---|---|---|
SDKProperty | interface | A single property extracted from an interface or class symbol. |
SDKType | interface | An SDK type descriptor extracted from the symbol graph. |
ReferenceEntry | interface | A single entry in the generated API reference. |
SDKProperty | interface | A single property extracted from an interface or class symbol. |
SDKType | interface | An SDK type descriptor extracted from the symbol graph. |
ReferenceEntry | interface | A single entry in the generated API reference. |
Other Exports
| Symbol | Kind | Description |
|---|---|---|
tsup.config.ts | file | |
schema-mapper.ts | file | |
sdk-extractor.ts | file | |
openapi.ts | file | |
reference.ts | file | |
index.ts | file | OpenAPI 3.2 spec generator and structured API reference builder for forge-ts.... |
api.test.ts | file | |
schema-mapper.ts | file | |
sdk-extractor.ts | file | |
openapi.ts | file | |
reference.ts | file | |
index.ts | file | forge-ts/api — OpenAPI spec and API reference generator. Extracts public SDK... |
api.test.ts | file |