![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
dfx-openapi
Advanced tools
dfx-openapi is a type-safe Angular HttpClient that pulls in your OpenAPI schema. It has virtually zero runtime and is fully compatible with Http Interceptors.
dfx-openapi
is a type-safe Angular HttpClient that pulls in your OpenAPI schema.
It has virtually zero runtime and is fully compatible with Http interceptors.
The syntax is inspired by openapi-fetch.
import { inject, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { createOpenAPIHttpClient } from 'dfx-openapi';
import type { paths } from './my-openapi-3-schema';
export function injectAPI() {
const httpClient = inject(HttpClient);
return createOpenAPIHttpClient<paths>(httpClient, { baseUrl: 'https://myapi.dev/v1/' });
}
@Injectable()
export class YourService {
private api = injectAPI();
// Return type (Oberservable<ItemResponse>) gets inferred
getItem(itemId: string) {
return this.api.get('/items/{item_id}', {
params: {
path: {
item_id: '1234',
},
},
});
}
// Return type (Oberservable<ItemResponse>) gets inferred
updateItem(id: string, name: string) {
return this.api.put('/items', {
body: {
// Body is type-safe
id,
name,
},
});
}
}
get()
, put()
, post()
, etc. are thin wrappers around the Angular HttpClient.
Notice there are no generics, and no manual typing. Your endpoint’s request and response were inferred automatically. This is a huge improvement in the type safety of your endpoints because every manual assertion could lead to a bug! This eliminates all of the following:
Angular | dfx-bootstrap-table | openapi-typescript-helpers |
---|---|---|
19.x.x | 0.1.0 | >=0.0.15 |
18.x.x | 0.0.3 | >=0.0.15 |
18.x.x | 0.0.2 | 0.0.13 |
Install this library along with openapi-typescript:
npm i dfx-openapi
npm i -D openapi-typescript
Highly recommended
Enable noUncheckedIndexedAccess in your
tsconfig.json
(docs)
Next, generate TypeScript types from your OpenAPI schema using openapi-typescript:
npx openapi-typescript ./path/to/api/v1.yaml -o ./src/app/api/v1.d.ts
The best part about using dfx-openapi
over oldschool codegen is no documentation needed.
dfx-openapi
encourages using your existing OpenAPI documentation rather than trying to find what function to import, or what parameters that function wants:
import { inject, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { createOpenAPIHttpClient } from 'dfx-openapi';
import type { paths } from './my-openapi-3-schema';
export function injectAPI() {
const httpClient = inject(HttpClient);
return createOpenAPIHttpClient<paths>(httpClient, { baseUrl: 'https://myapi.dev/v1/' });
}
@Injectable()
export class YourService {
private api = injectAPI();
// Return type (Oberservable<ItemResponse>) gets inferred
getItem(itemId: string) {
return this.api.get('/items/{item_id}', {
params: {
path: {
item_id: '1234',
},
},
});
}
// Return type (Oberservable<ItemResponse>) gets inferred
updateItem(id: string, name: string) {
return this.api.put('/items', {
body: {
// Body is type-safe
id,
name,
},
});
}
}
createOpenAPIHttpClient()
get()
, put()
, etc.The pathname of get()
, put()
, post()
, etc. must match your schema literally.
Note in the example, the URL is /items/{item_id}
.
This library will quickly replace all path
params for you (so they can be typechecked).
TIP
dfx-openapi infers types from the URL. Prefer static string values over dynamic runtime values, e.g.:
- ✅
"/items/{item_id}"
- ❌
[...pathParts].join("/") + "{item_id}"
This library also supports the label and matrix serialization styles as well (docs) automatically.
The get()
request shown needed the params
object that groups parameters by type (path
or query
).
If a required param is missing, or the wrong type, a type error will be thrown.
The post()
and put()
request required a body
object that provided all necessary requestBody data.
FAQs
dfx-openapi is a type-safe Angular HttpClient that pulls in your OpenAPI schema. It has virtually zero runtime and is fully compatible with Http Interceptors.
The npm package dfx-openapi receives a total of 0 weekly downloads. As such, dfx-openapi popularity was classified as not popular.
We found that dfx-openapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.