@genxapi/template-orval
v0.3.0
Published
GenX API Orval template - Adapter for API client generation workflows.
Downloads
295
Maintainers
Readme
@genxapi/template-orval
Reusable Orval template that supports generating multiple clients from a single configuration file. It:
- Loads JSON/YAML config files via
loadTemplateConfig/searchTemplateConfig. - Scaffolds the bundled template, applies token replacements, and consumes resolved contract inputs from GenX API.
- Generates Orval config and optionally executes Orval + hook scripts.
- Supports optional GitHub sync/pull request and npm publish settings (consumed by the CLI).
- Emits generated packages with separate
generate,build, andpublishscripts plusgenxapi.manifest.json.
Usage
import { loadTemplateConfig, generateClients } from "@genxapi/template-orval";
const config = await loadTemplateConfig("./orval-multi-client.config.json");
await generateClients(config);Example
// examples/petstore/genxapi.config.json
{
"$schema": "https://raw.githubusercontent.com/genxapi/genxapi/main/packages/cli/schemas/genxapi.schema.json",
"project": {
"name": "petstore-client",
"directory": "./examples/petstore/output",
"template": "orval",
"repository": {
"owner": "your-github-handle",
"name": "petstore-client",
"pullRequest": {
"title": "chore: refresh petstore client"
}
},
"publish": {
"npm": {
"enabled": true,
"command": "npm",
"tag": "latest"
}
},
"readme": {
"introduction": "Demo SDK generated from the public Petstore API.",
"additionalSections": [
{
"title": "Support",
"body": "Contact the platform team if you need additional endpoints exposed in this client."
}
]
}
},
"clients": [
{
"name": "pets",
"swagger": "https://petstore3.swagger.io/api/v3/openapi.json",
"config": {
"client": "react-query",
"httpClient": "axios",
"mock": { "type": "msw", "delay": 300 }
}
}
]
}Configuration Highlights
{
"project": {
"name": "demo-client",
"directory": "./clients/demo",
"template": "orval",
"repository": {
"owner": "your-handle",
"name": "demo-client-repo",
"pullRequest": { "branchPrefix": "chore/clients" }
}
},
"clients": [
{
"name": "pets",
"swagger": "./specs/petstore.yaml",
"config": {
"client": "react-query",
"httpClient": "axios",
"mock": { "type": "msw", "delay": 300 }
}
}
]
}See samples/orval-multi-client.config.json for a full example. Consumers should import the generated package boundary, not internal src/ or dist/ files.
