MetaEngine.TypeScript.OpenApi.Angular

Generate TypeScript models and Angular services from OpenAPI/Swagger specifications. Perfect for API-first development workflows where your API contract drives the implementation.

npm versionnpm downloadslicensenuget version
NPM Package

Use as a CLI tool via npm/npx

# Install globally
npm install -g @metaengine/openapi-angular
# Or use with npx
npx @metaengine/openapi-angular api.yaml ./output

Requirements: Node.js 18+, .NET 8.0+ runtime

NuGet Package

Use programmatically in .NET projects

# Install via dotnet CLI
dotnet add package MetaEngine.TypeScript.OpenApi.Angular

Requirements: .NET Standard 2.0+

Command Line Usage

Basic Syntax
npx @metaengine/openapi-angular <input> <output> [options]

Supports OpenAPI 3.0+ specifications in both JSON and YAML formats.

Quick Examples
# Generate from local file
npx @metaengine/openapi-angular api.yaml ./src/app/api
# Generate from URL
npx @metaengine/openapi-angular https://api.example.com/openapi.json ./src/app/api
# With Angular best practices
npx @metaengine/openapi-angular api.yaml ./src/app/api \
--provided-in root \
--documentation \
--error-handling \
--inject-function
CLI Options
OptionDescription
--provided-in <value>Angular injection scope (root, any, platform)
--base-url-token <name>Injection token name for base URL [default: BASE_URL]
--options-threshold <n>Parameter count to use options object [default: 4]
--documentationGenerate JSDoc comments
--inject-functionUse inject() instead of constructor injection (Angular 14+)
--http-resourceGenerate httpResource methods with Signals for GET operations (Angular 19.2+)
--error-handlingEnable smart error handling
--include-tags <tags>Filter by OpenAPI tags (comma-separated, case-insensitive)
--strict-validationEnable strict OpenAPI validation
--verboseEnable verbose logging
--help, -hShow help message

Programmatic Usage (C#)

Configuration Example
Configuration Example

Type Resolution

Automatically resolves and includes all referenced types from your OpenAPI specification.

Flexible Naming

Customize method and file naming conventions to match your project's standards.

Modern Angular

Support for Angular 14+ features including inject() function and standalone components.

Options Reference

Angular Options

  • WithBaseUrlToken(string)Injection token name for base URL (default: "BASE_URL")
  • WithErrorHandling()Enable smart error handling
  • WithErrorHandling(Func)Custom error handling per status code
  • WithInjectFunction()Use inject() instead of constructor DI (Angular 14+)
  • WithHttpResources()Generate httpResource methods with Signals for GET operations (Angular 19.2+)
  • WithProvidedIn(string)Injection scope ("root", "platform", "any")
  • WithMethodNames(Func)Custom method naming rule
  • WithDocumentation()Enable JSDoc comments
  • WithOptionsObjectThreshold(int)Parameter count for options object (default: 4)

OpenAPI Filtering

  • WithStrictValidation()Enable strict OpenAPI validation
  • WithOperationFilter(Func)Filter operations by predicate
  • WithHeaderFilter(Func)Filter header parameters

Naming Transformations

  • Types(Func)Transform type names
  • Paths(Func)Transform output paths
  • FileNames(Func)Transform file names

File Management

  • CleanDestination()Clean output directory before generation
  • AlwaysOverwrite()Always overwrite existing files
  • OnlyWhenModelChanged()Update only when model changes
  • OnlyWhenNew()Write only new files, preserve existing
  • CleanDirectories(...)Clean specific subdirectories

Diagnostics

  • EnableVerboseLogging()Enable detailed logging