diff --git a/README.md b/README.md index 8aa3e43..3d2720e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,23 @@ $ npm install -D @7nohe/openapi-react-query-codegen ``` + Register the command to the `scripts` property in your package.json file. + +```json +{ + "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. + +```bash +$ npx --package @7nohe/openapi-react-query-codegen openapi-rq -i ./petstore.yaml -c axios +``` + + ## Usage ``` diff --git a/examples/react-app/package.json b/examples/react-app/package.json index ae7e861..89f9b6a 100644 --- a/examples/react-app/package.json +++ b/examples/react-app/package.json @@ -13,19 +13,19 @@ "test:generated": "tsc ./openapi/queries/index.ts --noEmit --target esnext --moduleResolution node" }, "dependencies": { - "@tanstack/react-query": "^5.0.0", - "axios": "^1.4.0", + "@tanstack/react-query": "^5.4.3", + "axios": "^1.6.0", "form-data": "~4.0.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "@stoplight/prism-cli": "^5.0.0", + "@stoplight/prism-cli": "^5.5.1", "@types/react": "^18.2.6", "@types/react-dom": "^18.2.4", - "@vitejs/plugin-react": "^4.0.0", + "@vitejs/plugin-react": "^4.1.0", "npm-run-all": "^4.1.5", - "typescript": "^5.0.4", - "vite": "^4.3.8" + "typescript": "^5.2.2", + "vite": "^4.5.0" } } \ No newline at end of file diff --git a/examples/react-app/src/App.tsx b/examples/react-app/src/App.tsx index 207c618..220db20 100644 --- a/examples/react-app/src/App.tsx +++ b/examples/react-app/src/App.tsx @@ -4,34 +4,33 @@ import { useDefaultClientFindPets, useDefaultClientFindPetsKey, } from "../openapi/queries"; -import { useState } from 'react'; -import { queryClient } from './queryClient'; +import { useState } from "react"; +import { queryClient } from "./queryClient"; function App() { - const [tags, _setTags] = useState([]); const [limit, _setLimit] = useState(10); - const { data, error, refetch } = useDefaultClientFindPets( - { tags, limit }, - ); + const { data, error, refetch } = useDefaultClientFindPets({ tags, limit }); const { mutate: addPet } = useDefaultClientAddPet(); - if (error) return ( -
-

Failed to fetch pets

- -
- ); + if (error) + return ( +
+

Failed to fetch pets

+ +
+ ); return (

Pet List

    - {data instanceof Array && data?.map((pet, index) => ( -
  • {pet.name}
  • - ))} + {data instanceof Array && + data?.map((pet, index) => ( +
  • {pet.name}
  • + ))}