Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #101

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

> Node.js library that generates [React Query (also called TanStack Query)](https://tanstack.com/query) hooks based on an OpenAPI specification file.

[![npm version](https://badge.fury.io/js/%407nohe%2Fopenapi-react-query-codegen.svg)](https://badge.fury.io/js/%407nohe%2Fopenapi-react-query-codegen)

## Features

- Supports generation of custom react hooks that use React Query's `useQuery` and `useMutation` hooks
- Supports generation of query keys for query caching
- Supports the option to use pure TypeScript clients generated by [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts)
- Generates custom react hooks that use React Query's `useQuery`, `useSuspenseQuery` and `useMutation` hooks
- Generates query keys and functions for query caching
- Generates pure TypeScript clients generated by [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts)

## Install
## Installation

```
$ npm install -D @7nohe/openapi-react-query-codegen
Expand Down Expand Up @@ -58,15 +60,15 @@ Options:
-h, --help display help for command
```

## Example Usage
### Example Usage

### Command
#### Command

```
$ openapi-rq -i ./petstore.yaml
```

### Output directory structure
#### Output directory structure

```
- openapi
Expand All @@ -81,9 +83,9 @@ $ openapi-rq -i ./petstore.yaml

- [Prefetching docs](https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr#prefetching-and-dehydrating-data)

### In your app
#### In your app

#### Using the generated hooks
##### Using the generated hooks

```tsx
// App.tsx
Expand All @@ -102,7 +104,7 @@ function App() {
export default App;
```

#### Using the generated typescript client
##### Using the generated typescript client

```tsx
import { useQuery } from "@tanstack/react-query";
Expand All @@ -125,7 +127,7 @@ function App() {
export default App;
```

#### Using Suspense Hooks
##### Using Suspense Hooks

```tsx
// App.tsx
Expand Down Expand Up @@ -158,7 +160,7 @@ function App() {
export default App;
```

#### Runtime Configuration
##### Runtime Configuration

You can modify the default values used by the generated service calls by modifying the OpenAPI configuration singleton object.

Expand Down