Skip to content

Commit b81a8a0

Browse files
authored
Minor docs change (#1302)
1 parent 5939e20 commit b81a8a0

File tree

6 files changed

+215
-259
lines changed

6 files changed

+215
-259
lines changed

docs/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
},
1111
"dependencies": {
1212
"@algolia/client-search": "^4.19.1",
13-
"@astrojs/preact": "^2.2.1",
14-
"@astrojs/react": "^2.2.1",
13+
"@astrojs/preact": "^2.2.2",
14+
"@astrojs/react": "^2.2.2",
1515
"@docsearch/css": "^3.5.1",
1616
"@docsearch/react": "^3.5.1",
17-
"@types/react": "^18.2.16",
17+
"@types/react": "^18.2.20",
1818
"@types/react-dom": "^18.2.7",
19-
"astro": "^2.9.2",
20-
"preact": "^10.16.0",
19+
"astro": "^2.10.9",
20+
"preact": "^10.17.0",
2121
"react": "^18.2.0",
2222
"react-dom": "^18.2.0",
23-
"sass": "^1.64.1"
23+
"sass": "^1.65.1"
2424
},
2525
"devDependencies": {
26-
"@astrojs/sitemap": "^2.0.1",
27-
"@types/node": "^20.4.9",
26+
"@astrojs/sitemap": "^2.0.2",
27+
"@types/node": "^20.5.0",
2828
"html-escaper": "^3.0.3",
2929
"typescript": "^5.1.6"
3030
}

docs/src/content/docs/advanced.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ However, APIs are language-agnostic, and may contain a different syntax style fr
182182
183183
Instead, treat “consistency” in a more holistic sense, recognizing that preserving the API schema as-written is better than adhering to language-specific style conventions.
184184
185-
### Enable `noUncheckedIndexAccess` in your tsconfig.json
185+
### Enable `noUncheckedIndexedAccess` in your tsconfig.json
186186
187-
openapi-typescript generates a `Record` for `additionalProperties` and tries to avoid adding a `undefined` union to the index signature. However, this may result in unsafe property access in TypeScript, **unless** the compiler flag `noUncheckedIndexAccess` is set. If set, TypeScript will error when you try to access a property that might not be set.
187+
openapi-typescript generates a `Record` for `additionalProperties` and tries to avoid adding a `undefined` union to the index signature. However, this may result in unsafe property access in TypeScript, **unless** the compiler flag `noUncheckedIndexedAccess` is set ([docs](/advanced#enable-nouncheckedindexaccess-in-your-tsconfigjson)). If set, TypeScript will error when you try to access a property that might not be set.
188188
189189
### Be specific in your schema
190190

docs/src/content/docs/introduction.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ This library requires the latest version of <a href="https://nodejs.org/en" targ
3030
npm i -D openapi-typescript
3131
```
3232

33+
> **Tip**
34+
>
35+
> Enabling [noUncheckedIndexedAccess](https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess) in `tsconfig.json` can go along way to improve type safety ([read more](/advanced#enable-nouncheckedindexaccess-in-your-tsconfigjson))
36+
3337
## Basic usage
3438

3539
First, generate a local type file by running `npx openapi-typescript`:
@@ -62,10 +66,6 @@ type SuccessResponse = paths["/my/endpoint"]["get"]["responses"][200]["content"]
6266
type ErrorResponse = paths["/my/endpoint"]["get"]["responses"][500]["content"]["application/json"]["schema"];
6367
```
6468

65-
> **Tip**
66-
>
67-
> Using TypeScript’s bracket notation (`obj["property"]`) is a safe way to access all names in your OpenAPI schema, even the ones that aren’t “TypeScript-safe”
68-
6969
From here, you can use these types for any of the following (but not limited to):
7070

7171
- Using an OpenAPI-supported fetch client (like [openapi-fetch](/openapi-fetch))

packages/openapi-typescript/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,30 @@ openapi-typescript generates TypeScript types from static <a href="https://spec.
44

55
The code is [MIT-licensed](./LICENSE) and free for use.
66

7-
**Features**
7+
## Features
88

99
- ✅ Supports OpenAPI 3.0 and 3.1 (including advanced features like <a href="https://spec.openapis.org/oas/v3.1.0#discriminator-object" target="_blank" rel="noopener noreferrer">discriminators</a>)
1010
- ✅ Generate **runtime-free types** that outperform old-school codegen
1111
- ✅ Load schemas from YAML or JSON, locally or remotely
1212
- ✅ Native Node.js code is fast and generates types within milliseconds
1313

14-
**Examples**
14+
## Examples
1515

1616
👀 [See examples](./examples/)
1717

18-
## Usage
18+
## Setup
19+
20+
This library requires the latest version of <a href="https://nodejs.org/en" target="_blank" rel="noopener noreferrer">Node.js</a> installed (20.x or higher recommended). With that present, run the following in your project:
21+
22+
```bash
23+
npm i -D openapi-typescript
24+
```
25+
26+
> **Tip**
27+
>
28+
> Enabling [noUncheckedIndexedAccess](https://www.typescriptlang.org/tsconfig#noUncheckedIndexedAccess) in `tsconfig.json` can go along way to improve type safety ([read more](/advanced#enable-nouncheckedindexaccess-in-your-tsconfigjson))
29+
30+
## Basic usage
1931

2032
First, generate a local type file by running `npx openapi-typescript`:
2133

packages/openapi-typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"devDependencies": {
6969
"@types/degit": "^2.8.3",
7070
"@types/js-yaml": "^4.0.5",
71-
"@types/node": "^20.4.9",
71+
"@types/node": "^20.5.0",
7272
"degit": "^2.8.4",
7373
"del-cli": "^5.0.0",
7474
"esbuild": "^0.19.2",

0 commit comments

Comments
 (0)