-
-
Notifications
You must be signed in to change notification settings - Fork 528
fix docs typos #1836
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
fix docs typos #1836
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,7 +8,7 @@ It works by using [openapi-fetch](../openapi-fetch) and [openapi-typescript](../ | |||||
- ✅ All parameters, request bodies, and responses are type-checked and 100% match your schema | ||||||
- ✅ No manual typing of your API | ||||||
- ✅ Eliminates `any` types that hide bugs | ||||||
- ✅ Also eliminates `as` type overrides that can also hide bugs | ||||||
- ✅ Eliminates `as` type overrides that can also hide bugs | ||||||
|
||||||
## Setup | ||||||
|
||||||
|
@@ -25,42 +25,42 @@ Next, generate TypeScript types from your OpenAPI schema using openapi-typescrip | |||||
npx openapi-typescript ./path/to/api/v1.yaml -o ./src/lib/api/v1.d.ts | ||||||
``` | ||||||
|
||||||
> ⚠️ Be sure to <a href="https://redocly.com/docs/cli/commands/lint/" target="_blank" rel="noopener noreferrer">validate your schemas</a>! openapi-typescript will err on invalid schemas. | ||||||
> ⚠️ Be sure to <a href="https://redocly.com/docs/cli/commands/lint/" target="_blank" rel="noopener noreferrer">validate your schemas</a>! openapi-typescript will error on invalid schemas. | ||||||
|
||||||
## Usage | ||||||
|
||||||
Once your types has been generated from your schema, you can create a [fetch client](../openapi-fetch), a react-query client and start querying your API. | ||||||
Once your types have been generated from your schema, you can create a [fetch client](../openapi-fetch), a react-query client and start querying your API. | ||||||
|
||||||
```tsx | ||||||
import createFetchClient from "openapi-fetch"; | ||||||
import createClient from "openapi-react-query"; | ||||||
import type { paths } from "./my-openapi-3-schema"; // generated by openapi-typescript | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use double quotes in this repository and I think we should keep documentation with the same rules (default biome ones) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated, thanks. My autoformat on save was the culprit, lol. |
||||||
import createFetchClient from 'openapi-fetch'; | ||||||
import createClient from 'openapi-react-query'; | ||||||
import type { paths } from './my-openapi-3-schema'; // generated by openapi-typescript | ||||||
|
||||||
const fetchClient = createFetchClient<paths>({ | ||||||
baseUrl: "https://myapi.dev/v1/", | ||||||
baseUrl: 'https://myapi.dev/v1/', | ||||||
}); | ||||||
const $api = createClient(fetchClient); | ||||||
|
||||||
const MyComponent = () => { | ||||||
const { data, error, isLoading } = $api.useQuery( | ||||||
"get", | ||||||
"/blogposts/{post_id}", | ||||||
const { data, error, isPending } = $api.useQuery( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? I’m confused; this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have v5 as a peer dependency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah thanks for explaining! I missed that. I think we have some other docs out-of-date, then. This is good for now! |
||||||
'get', | ||||||
'/blogposts/{post_id}', | ||||||
{ | ||||||
params: { | ||||||
path: { post_id: 5 }, | ||||||
}, | ||||||
}, | ||||||
} | ||||||
); | ||||||
|
||||||
if (isLoading || !data) return "Loading..."; | ||||||
if (isPending || !data) return 'Loading...'; | ||||||
|
||||||
if (error) return `An error occured: ${error.message}`; | ||||||
if (error) return `An error occurred: ${error.message}`; | ||||||
|
||||||
return <div>{data.title}</div>; | ||||||
}; | ||||||
``` | ||||||
|
||||||
> You can find more information about `createFetchClient` on the [openapi-fetch documentation](../openapi-fetch). | ||||||
> You can find more information about `createFetchClient` in the [openapi-fetch documentation](../openapi-fetch). | ||||||
|
||||||
## 📓 Docs | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“err“ is correct; that is a verb. “Error” is a noun, so this isn’t correct.
However, this sentence only applies to 6.x, not 7.x (since that will validate). So we could just remove this altogether.