@darkpatternsdigital/openapi-codegen-typescript-rxjs
v0.9.0
Published
A typescript client code generator for principled development using RxJS
Downloads
72
Readme
OpenAPI Codegen for a TypeScript-friendly RxJS client
Provides an adapter layer method for @darkpatternsdigital/openapi-codegen-typescript to integrate with rxjs.
npm i @darkpatternsdigital/openapi-codegen-typescript
npm i -D @darkpatternsdigital/openapi-codegen-typescript-rxjs
You must also have the .NET 8.0 runtime installed on your machine.
This will provide a corresponding bin to generate the typescript files. (See the @darkpatternsdigital/openapi-codegen-typescript package for command line usage details.)
openapi-codegen-typescript api.yaml api-generated/ -c
You can then create an API wrapper such as:
import { toRxjsApi } from '@darkpatternsdigital/openapi-codegen-typescript-rxjs';
import operations from './api-generated/operations';
const baseDomain = 'http://localhost/';
export default toRxjsApi(operations, baseDomain);
To use within node (such as unit tests), use the universal-rxjs-ajax
npm module:
import { toRxjsApi } from '@darkpatternsdigital/openapi-codegen-typescript-rxjs';
import operations from './api-generated/operations';
import { request as ajax } from 'universal-rxjs-ajax';
const baseDomain = 'http://localhost/';
export default toRxjsApi(operations, baseDomain, ajax);
This API will use the type safety from OpenAPI along with rxjs.