
Security News
6 AppSec CTOs Debate Open Source Supply Chain Security at Black Hat
Socket CTO Ahmad Nassri joins AppSec leaders at Black Hat to discuss active malware, package manager risks, and software supply chain defense.
@7nohe/openapi-react-query-codegen
Advanced tools
Affected versions:
Node.js library that generates React Query (also called TanStack Query) hooks based on an OpenAPI specification file.
useQuery and useMutation hooks$ npm install -D @7nohe/openapi-react-query-codegen
$ openapi-rq --help
Usage: openapi-rq [options]
Generate React Query code based on OpenAPI
Options:
-V, --version output the version number
-p, --path <path> Path to OpenAPI file
-o, --output-dir [directory] Directory to output the generated package (default: "openapi")
-h, --help display help for command
$ openapi-rq -p ./petstore.yaml
- openapi
- queries
- index.ts <- custom react hooks
- requests <- output code generated by OpenAPI Typescript Codegen
// App.tsx
import {
usePetServiceFindPetsByStatus,
} from "../openapi/queries";
function App() {
const { data } = usePetServiceFindPetsByStatus({ status: ["available"] });
return (
<div className="App">
<h1>Pet List</h1>
<ul>
{data?.map((pet) => (
<li key={pet.id}>{pet.name}</li>
))}
</ul>
</div>
);
}
export default App;
You can also use pure TS clients.
import { useQuery } from "@tanstack/react-query";
import { PetService } from '../openapi/requests/services/PetService';
function App() {
const { data } = useQuery(['MyKey'], () => {
// Do something here
return PetService.findPetsByStatus(['available']);
});
return (
<div className="App">
{/* .... */}
</div>
);
}
export default App;
MIT
FAQs
OpenAPI React Query Codegen
The npm package @7nohe/openapi-react-query-codegen receives a total of 132,487 weekly downloads. As such, @7nohe/openapi-react-query-codegen popularity was classified as popular.
We found that @7nohe/openapi-react-query-codegen 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.

Security News
Socket CTO Ahmad Nassri joins AppSec leaders at Black Hat to discuss active malware, package manager risks, and software supply chain defense.

Research
/Security News
Thirteen malicious Packagist themes expose visitors on unpatched iPhones to a WebKit-to-kernel exploit chain that steals device data and wallet seeds.

Research
/Security News
Ten malicious OpenAPI React Query Codegen versions were published to npm in the Mini Shai-Hulud attack, all with valid provenance.