@metaengine/openapi-angular
v1.1.0
Published
Generate TypeScript/Angular services and models from OpenAPI specifications with httpResource (Angular 19.2+) and Signal-based data fetching support
Downloads
412
Maintainers
Readme
@metaengine/openapi-angular
Generate TypeScript/Angular services and models from OpenAPI specifications.
Install
npm install --save-dev @metaengine/openapi-angularOr use directly with npx:
npx @metaengine/openapi-angular <input> <output>Requirements
- Node.js 14.0 or later
- .NET 8.0 or later runtime (Download)
- Angular 14.0 or later (for generated code)
Quick start
npx @metaengine/openapi-angular api.yaml ./src/app/api \
--inject-function \
--error-handling \
--documentationCLI options
| Option | Description | Default |
|--------|-------------|---------|
| --include-tags <tags> | Filter by OpenAPI tags (comma-separated, case-insensitive) | - |
| --provided-in <value> | Angular injection scope (root, any, platform) | - |
| --base-url-token <name> | Injection token name for base URL | BASE_URL |
| --options-threshold <n> | Parameter count for options object | 4 |
| --documentation | Generate JSDoc comments | false |
| --inject-function | Use inject() instead of constructor injection | false |
| --http-resource | Use httpResource with Signals for HTTP calls (Angular 19.2+) | false |
| --lazy-resource | Add trigger signal for lazy loading (implies --http-resource) | false |
| --error-handling | Enable smart error handling | false |
| --strict-validation | Enable strict OpenAPI validation | false |
| --date-transformation | Convert date strings in responses to Date objects | false |
| --interceptors | Generate Angular interceptors for cross-cutting concerns | false |
| --clean | Clean output directory (remove files not in generation) | false |
| --verbose | Enable verbose logging | false |
| --type-mapping <slug=target> | Override TS type for an OpenAPI format. Repeatable. See Type mapping overrides | - |
| --help, -h | Show help message | - |
Type mapping overrides
Use --type-mapping to override the TS type emitted for a given OpenAPI (type, format) pair. Repeatable. Unknown slugs and unknown targets are hard errors.
| Slug | OpenAPI (type, format) | Default | --type-mapping value |
|------|--------------------------|---------|------------------------|
| int64 | (integer, int64) | number | int64=bigint |
| decimal | (number, decimal) | number | decimal=string |
| date-time | (string, date-time) | Date | date-time=string |
| date | (string, date) | Date | date=string |
npx @metaengine/openapi-angular api.yaml ./src/app/api \
--type-mapping int64=bigint \
--type-mapping date-time=stringSee it live
Try the generator with your own spec at https://www.metaengine.eu/converters.
License
MIT
Support
For issues and feature requests, please visit: https://github.com/meta-engine/openapi-angular/issues
