API Reference

genapi provides multiple packages, each with specific functionality.

Package Overview

@genapi/core

Core package providing configuration definition and CLI functionality.

import { defineConfig } from '@genapi/core'

@genapi/presets

Presets package: HTTP client and data-layer pipelines (axios, fetch, ky, got, ofetch, uni, tanstackQuery with react/vue/colada).

import { axios, fetch, tanstackQuery } from '@genapi/presets'

@genapi/parser

Parser package for OpenAPI: traverse, transform, and createParser for building preset parsers.

import { createParser, traversePaths } from '@genapi/parser'

@genapi/pipeline

Pipeline package providing core functionality of the pipeline system.

import pipeline, { compiler, dest, generate, original } from '@genapi/pipeline'

@genapi/transform

Transform package providing specification conversion functionality (e.g., Swagger 2.0 to OpenAPI 3.0).

import { swagger2ToSwagger3 } from '@genapi/transform'

@genapi/shared

Shared package providing type definitions and utility functions.

import type { Config } from '@genapi/shared'

Type Definitions

Config

Main configuration type from @genapi/shared (namespace ApiPipeline):

import type { ApiPipeline } from '@genapi/shared'

const config: ApiPipeline.Config = {
  preset: 'swag-axios-ts', // or a pipeline function, e.g. axios.ts
  input: 'https://petstore3.swagger.io/api/v3/openapi.json',
  output: { main: 'src/api/index.ts', type: 'src/api/index.type.ts' },
  meta: {},
  patch: {},
  transform: {},
  parser: 'swagger',
}

CLI Commands

genapi provides command-line tools:

# Generate API
npx genapi

# View help
npx genapi --help