npm NuGet v1.1.0 MIT
@metaengine/openapi-react
OpenAPI 3.x → React hooks with TanStack Query (useQuery, useMutation) and native Fetch API. Tree-shakeable, typed, React 18+.
Install
Pick your registry
The same generator, published to every ecosystem we support. Install however your project expects.
npmPrimary@metaengine/openapi-react
$npm install @metaengine/openapi-react
v1.1.0
NuGetMetaEngine.TypeScript.OpenApi.React
$dotnet add package MetaEngine.TypeScript.OpenApi.React
v1.1.0
Usage
Drive it from the CLI or programmatically
npm ships a zero-config CLI. NuGet ships the same generator as a C# fluent API — same options, same output.
npm · npx · CI-friendly
After install, point the CLI at your OpenAPI spec. It writes the generated tree to your chosen output directory.
Basic syntax
npx @metaengine/openapi-react <input> <output> [options]Supports OpenAPI 3.0+ specifications in both JSON and YAML formats.
Quick examples
Generate from a local file
npx @metaengine/openapi-react api.yaml ./src/apiGenerate from a URL
npx @metaengine/openapi-react https://api.example.com/openapi.json ./src/apiWith TanStack Query and Vite
npx @metaengine/openapi-react api.yaml ./src/api \
--tanstack-query \
--documentation \
--base-url-env VITE_API_URLCLI options
Option
Description
--base-url-env <name>
Environment variable name for base URL [default: REACT_APP_API_BASE_URL]
--service-suffix <suffix>
Service naming suffix [default: Api]
--tanstack-query
Enable TanStack Query integration
--documentation
Generate JSDoc comments
--options-threshold <n>
Parameter count to use options object [default: 4]
--include-tags <tags>
Filter by OpenAPI tags (comma-separated, case-insensitive)
--strict-validation
Enable strict OpenAPI validation
--date-transformation
Convert date strings in responses to JavaScript Date objects
--clean
Clean output directory (remove files not in generation)
--verbose
Enable verbose logging
--help, -h
Show help message
Options reference
Every knob, documented
Every option is available on the CLI as a flag and on the programmatic C# API as a fluent method. Defaults shown in the right column.
React Options
7WithBaseUrlEnvVar(string)Environment variable name for base URL (default: "REACT_APP_API_BASE_URL")WithServiceSuffix(string)Service suffix (default: "Api")WithTanStackQuery(bool)Generate TanStack Query hooks (default: false)WithMethodNames(Func)Custom method naming ruleWithDocumentation()Enable JSDoc commentsWithOptionsObjectThreshold(int)Parameter count for options object (default: 4)WithResponseDateTransformation()Convert date/date-time strings in responses to Date objects
OpenAPI Filtering
3WithStrictValidation()Enable strict OpenAPI validationWithOperationFilter(Func)Filter operations by predicateWithHeaderFilter(Func)Filter header parameters
Naming Transformations
3Types(Func)Transform type namesPaths(Func)Transform output pathsFileNames(Func)Transform file names
File Management
5CleanDestination()Clean output directory before generationAlwaysOverwrite()Always overwrite existing filesOnlyWhenModelChanged()Update only when model changesOnlyWhenNew()Write only new files, preserve existingCleanDirectories(...)Clean specific subdirectories
Diagnostics
1EnableVerboseLogging()Enable detailed logging
Features
Why this package is different
Deterministic output
Same spec + same options produce byte-identical files. Safe to commit, safe to diff in review, safe to cache in CI.
Tree-shakeable
One file per tag (or per operation) means bundlers drop unused code at build time. No runtime dispatch table.
Zero runtime
Validation and clients opt in. The default emit is pure types with no dependency surface beyond your HTTP lib.
Flexible naming
Case conventions configurable per role — types, properties, operations, enums. Idiomatic in the target by default.
Type resolution
Discriminated unions for oneOf, proper nullability, bigint when the spec mandates it, refs flattened only when safe.
Semver-honest
Spec diff drives the version bump. Additive changes = minor, removed ops = major. Never a surprise in your lockfile.