
Research
/Security News
OpenAPI React Query Codegen Compromised in Mini Shai-Hulud npm Supply Chain Attack
Ten malicious OpenAPI React Query Codegen versions were published to npm in the Mini Shai-Hulud attack, all with valid provenance.
@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
Register the command to the scripts property in your package.json file.
{
"scripts": {
"codegen": "openapi-rq -i ./petstore.yaml -c axios"
}
}
You can also run the command without installing it in your project using the npx command.
$ npx --package @7nohe/openapi-react-query-codegen openapi-rq -i ./petstore.yaml -c axios
$ openapi-rq --help
Usage: openapi-rq [options]
Generate React Query code based on OpenAPI
Options:
-V, --version output the version number
-i, --input <value> OpenAPI specification, can be a path, url or string content (required)
-o, --output <value> Output directory (default: "openapi")
-c, --client <value> HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch")
--useUnionTypes Use union types (default: false)
--exportSchemas <value> Write schemas to disk (default: false)
--indent <value> Indentation options [4, 2, tabs] (default: "4")
--postfixServices <value> Service name postfix (default: "Service")
--postfixModels <value> Modal name postfix
--request <value> Path to custom request file
-h, --help display help for command
$ openapi-rq -i ./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';
import {
usePetServiceFindPetsByStatusKey,
} from "../openapi/queries";
function App() {
// You can still use the auto-generated query key
const { data } = useQuery([usePetServiceFindPetsByStatusKey], () => {
// 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 110,892 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.

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

Security News
Socket joins more than 100 technology, cybersecurity, and financial organizations calling for a global surge in cyber defense.

Product
Enterprise security teams can now detect malware, credential theft, suspicious network activity, and risky updates across Microsoft Edge extensions.