Skip to content

Commit 60516f8

Browse files
authored
Docs update (#1579)
1 parent 866ad55 commit 60516f8

File tree

13 files changed

+406
-332
lines changed

13 files changed

+406
-332
lines changed

docs/.vitepress/theme/style.css

+6
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,15 @@ code {
208208
display: flex;
209209
flex-wrap: wrap;
210210
gap: 2.5rem;
211+
list-style: none;
211212
justify-content: center;
212213
}
213214

215+
.logo-salad-list li {
216+
display: flex;
217+
list-style: none;
218+
}
219+
214220
.logo-salad-list svg {
215221
fill: var(--vp-c-text-1);
216222
width: auto;

docs/6.x/about.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ These 2 projects are unrelated. openapi-typescript-codegen is a Node.js alternat
5050

5151
### vs. tRPC
5252

53-
[tRPC](https://trpc.io/) is an opinionated typesafe framework for both server and client. It demands both your server and client be written in tRPC (which means Node.js for the backend).
53+
[tRPC](https://trpc.io/) is an opinionated type-safe framework for both server and client. It demands both your server and client be written in tRPC (which means Node.js for the backend).
5454

5555
If you fit into this usecase, it’s a great experience! But for everyone else, openapi-typescript (and openapi-fetch) is a more flexible, lower-level solution that can work for any technology choice (or even be incrementally-adopted without any cost).
5656

docs/about.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ These 2 projects are unrelated. openapi-typescript-codegen is a Node.js alternat
4949

5050
### vs. tRPC
5151

52-
[tRPC](https://trpc.io/) is an opinionated typesafe framework for both server and client. It demands both your server and client be written in tRPC (which means Node.js for the backend).
52+
[tRPC](https://trpc.io/) is an opinionated type-safe framework for both server and client. It demands both your server and client be written in tRPC (which means Node.js for the backend).
5353

5454
If you fit into this use case, it’s a great experience! But for everyone else, openapi-typescript (and openapi-fetch) is a more flexible, lower-level solution that can work for any technology choice (or even be incrementally-adopted without any cost).
5555

docs/data/contributors.json

+1-1
Large diffs are not rendered by default.

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ hero:
1515

1616
features:
1717
- title: Blazing Fast
18-
details: Nothing is faster than instant. Static TypeScript types provide zero runtime performance and zero client weight.
18+
details: Nothing is faster than instant. Static TypeScript types provide zero runtime cost and zero client weight.
1919
- title: Type-safe
2020
details: Use your OpenAPI schema to typecheck your entire codebase with no setup and no tests.
2121
- title: Works anywhere

docs/openapi-fetch/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: openapi-fetch
44

55
<img src="/assets/openapi-fetch.svg" alt="openapi-fetch" width="216" height="40" />
66

7-
openapi-fetch is a typesafe fetch client that pulls in your OpenAPI schema. Weighs **5 kb** and has virtually zero runtime. Works with React, Vue, Svelte, or vanilla JS.
7+
openapi-fetch is a type-safe fetch client that pulls in your OpenAPI schema. Weighs **5 kb** and has virtually zero runtime. Works with React, Vue, Svelte, or vanilla JS.
88

99
| Library | Size (min) | “GET” request |
1010
| :------------------------- | ---------: | :------------------------- |

docs/scripts/update-contributors.js

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const OPENAPI_TS_CONTRIBUTORS = [
133133
"hrsh7th",
134134
"davidleger95",
135135
"phk422",
136+
"mzronek",
136137
]),
137138
];
138139

docs/zh/openapi-fetch/api.md

+49-51
Large diffs are not rendered by default.

docs/zh/openapi-fetch/index.md

+10-13
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ await client.PUT("/blogposts", {
4040

4141
`data``error`经过类型检查,并将其类型暴露给VS Code(以及任何其他支持TypeScript的IDE)的智能感知。同样,请求`body`也将检查其字段,如果缺少任何必需的参数或存在类型不匹配,则会出错。
4242

43-
`GET()``PUT()``POST()`等是对原生 [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) 的轻量包装(您可以 [替换为任何调用](/openapi-fetch/zh/api#create-client))。
43+
`GET()``PUT()``POST()`等是对原生 [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) 的轻量包装(您可以 [替换为任何调用](/zh/openapi-fetch/api#create-client))。
4444

4545
请注意,没有泛型,也没有手动类型化。您的端点的请求和响应已自动推断。这对于端点的类型安全性是一个巨大的改进,因为**每个手动断言都可能导致错误**!这消除了以下所有问题:
4646

@@ -94,7 +94,6 @@ npx openapi-typescript ./path/to/api/v1.yaml -o ./src/lib/api/v1.d.ts
9494
使用 `tsc --noEmit` 来检查类型错误,而不要依赖于您的 linter 或构建命令。没有什么比 TypeScript 编译器本身更能准确地检查类型。
9595
:::
9696

97-
9897
## 基本用法
9998

10099
使用 `openapi-fetch` 而不是传统的代码生成的最大优点是不需要文档。`openapi-fetch` 鼓励使用现有的 OpenAPI 文档,而不是试图找出要导入的函数或该函数需要哪些参数:
@@ -109,9 +108,7 @@ const client = createClient<paths>({ baseUrl: "https://myapi.dev/v1/" });
109108

110109
const { data, error } = await client.GET("/blogposts/{post_id}", {
111110
params: {
112-
path: { post_id: "my-post"
113-
114-
},
111+
path: { post_id: "my-post" },
115112
query: { version: 2 },
116113
},
117114
});
@@ -158,16 +155,16 @@ const { data, error } = await client.PUT("/blogposts", {
158155
const { data, error, response } = await client.GET("/url");
159156
```
160157

161-
| 对象 | 响应 |
162-
| :--------- | :----------------------------------------------------------- |
163-
| `data` | 如果 OK 则为 `2xx` 响应;否则为 `undefined` |
164-
| `error` | 如果不是 OK,则为 `5xx``4xx``default` 响应;否则为 `undefined` |
158+
| 对象 | 响应 |
159+
| :--------- | :------------------------------------------------------------------------------------------------ |
160+
| `data` | 如果 OK 则为 `2xx` 响应;否则为 `undefined` |
161+
| `error` | 如果不是 OK,则为 `5xx``4xx``default` 响应;否则为 `undefined` |
165162
| `response` | [原始响应](https://developer.mozilla.org/en-US/docs/Web/API/Response) 包含 `status``headers`|
166163

167164
## 支持
168165

169-
| 平台 | 支持 |
170-
| :------------- | :----------------------------------------------------------- |
166+
| 平台 | 支持 |
167+
| :------------- | :------------------------------------------------------------------------------------------------------------------------------------ |
171168
| **浏览器** | [查看 fetch API 支持](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#browser_compatibility)(在所有主流浏览器中广泛可用) |
172-
| **Node** | >= 18.0.0 |
173-
| **TypeScript** | >= 4.7(建议使用 >= 5.0) |
169+
| **Node** | >= 18.0.0 |
170+
| **TypeScript** | >= 4.7(建议使用 >= 5.0) |

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"devDependencies": {
1717
"@changesets/changelog-github": "^0.5.0",
1818
"@changesets/cli": "^2.27.1",
19-
"@typescript-eslint/eslint-plugin": "^7.0.1",
20-
"@typescript-eslint/parser": "^7.0.1",
19+
"@typescript-eslint/eslint-plugin": "^7.1.1",
20+
"@typescript-eslint/parser": "^7.1.1",
2121
"del-cli": "^5.1.0",
22-
"eslint": "^8.56.0",
22+
"eslint": "^8.57.0",
2323
"eslint-config-prettier": "^9.1.0",
2424
"eslint-plugin-import": "^2.29.1",
2525
"eslint-plugin-no-only-tests": "^3.1.0",

packages/openapi-fetch/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="../../docs/public/assets/openapi-fetch.svg" alt="openapi-fetch" width="216" height="40" />
22

3-
openapi-fetch is a typesafe fetch client that pulls in your OpenAPI schema. Weighs **4 kB** and has virtually zero runtime. Works with React, Vue, Svelte, or vanilla JS.
3+
openapi-fetch is a type-safe fetch client that pulls in your OpenAPI schema. Weighs **4 kB** and has virtually zero runtime. Works with React, Vue, Svelte, or vanilla JS.
44

55
| Library | Size (min) | “GET” request |
66
| :------------------------- | ---------: | :------------------------- |

packages/openapi-fetch/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-fetch",
3-
"description": "Fast, typesafe fetch client for your OpenAPI schema. Only 5 kb (min). Works with React, Vue, Svelte, or vanilla JS.",
3+
"description": "Fast, type-safe fetch client for your OpenAPI schema. Only 5 kb (min). Works with React, Vue, Svelte, or vanilla JS.",
44
"version": "0.9.2",
55
"author": {
66
"name": "Drew Powers",

0 commit comments

Comments
 (0)