Skip to content

Config reference

The config is data: openapi-forge.config.yaml, .yml or .json, or an rc file (.openapi-forgerc, with the same .yaml, .yml and .json variants), searched in the folder you run it from in that order, or any file you pass with --config. A file ending in .json is read as JSON and any other as YAML, which includes the rc file with no extension; JSON is valid YAML, so that file may hold either. All keys are optional. An option the tool does not know, such as a typo, is an error that names the file and lists the valid ones.

input: openapi.json # file | URL | folder of documents | { service: fileOrUrl }
out: src/api/generated
apiPrefix: /api/v1 # stripped from every route
baseUrlEnv: VITE_API_URL # the variable axios / fetch / Angular read the base URL from; api-client finds its own
client: builtin # builtin | custom
target: hooks # hooks | requests
library: react-query # vue-query | svelte-query | solid-query | angular-query | swr
http: api-client # fetch | axios | angular - for the built-in runtime
tags: { include: [], exclude: [] }
zod: false
infinite: false
headers: { Authorization: "Bearer …" } # for a URL input
tls: { insecure: false, ca: internal-ca.pem }
format: prettier # or false
sources: { users: "https://host/users/openapi.yaml" } # for `pull`
specsDir: openapi-specs
decisionsFile: openapi-forge.decisions.json
generatorName: openapi-forge # the banner of every file
verbose: false
# runtime: see "Your own transport"
# transform: see "Opt-in extras" (functions: only a script config can hold it)

A script (openapi-forge.config.mjs, .js or .cjs) is read after all of these. It is the only place transform can go. It default-exports the object, or a function (sync or async) that returns it, and defineConfig only gives your editor the types:

import { defineConfig } from "@mrzr/openapi-forge";
export default defineConfig({ input: "openapi.json", transform: { /* see "Opt-in extras" */ } });