You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/about.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -23,11 +23,11 @@ description: Additional info about this project
23
23
## Project goals
24
24
25
25
1. Support converting any valid OpenAPI schema to TypeScript types, no matter how complicated.
26
-
1.Generate **runtime-free types** for maximum performance.
27
-
1.This library does **NOT**validate your schema, there existing libraries for that (like [`redocly lint`](https://redocly.com/docs/cli/commands/lint/)).
28
-
1.The generated TypeScript types **must** match your schema as closely as possible (e.g. no renaming to `PascalCase`)
29
-
1.This library should never require Java, node-gyp, or some other complex environment to work. This should require Node.js and nothing else.
30
-
1.This library will never require a running OpenAPI server to work.
26
+
1.Generated types should be statically-analyzable and runtime-free (with minor exceptions like <ahref="https://www.typescriptlang.org/docs/handbook/enums.html"target="_blank"rel="noopener noreferrer">enums</a>).
27
+
1.Don’t validate schemas; there are existing libraries for that like <ahref="https://redocly.com/docs/cli/commands/lint/"target="_blank"rel="noopener noreferrer">Redocly</a>.
28
+
1.Generated types should match your original schema as closely as possible, preserving original capitalization, etc.
29
+
1.Typegen only needs Node.js to run (no Java, Python, etc.) and works in any environment.
30
+
1.Support fetching OpenAPI schemas from files as well as local and remote servers.
Copy file name to clipboardExpand all lines: docs/src/content/docs/openapi-fetch/about.md
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,24 @@ description: openapi-fetch About
5
5
6
6
## Project Goals
7
7
8
-
1.Infer types automatically from OpenAPI schemas **without generics** (or, only the absolute minimum needed)
9
-
2. Respect the native Fetch API while reducing boilerplate (such as `await res.json()`)
10
-
3. Be as small and light as possible
8
+
1.Types should be strict and inferred automatically from OpenAPI schemas with the absolute minimum number of generics needed.
9
+
2. Respect the native Fetch API while reducing boilerplate (such as `await res.json()`).
10
+
3. Be as light and performant as possible.
11
11
12
-
## Differences from openapi-typescript-fetch
12
+
## Differences
13
+
14
+
### From openapi-typescript-fetch
13
15
14
16
This library is identical in purpose to [openapi-typescript-fetch](https://github.com/ajaishankar/openapi-typescript-fetch), but has the following differences:
15
17
16
18
- This library has a built-in `error` type for `3xx`/`4xx`/`5xx` errors whereas openapi-typescript-fetch throws exceptions (requiring you to wrap things in `try/catch`)
17
19
- This library has a more terse syntax (`get(…)`) wheras openapi-typescript-fetch requires chaining (`.path(…).method(…).create()`)
18
20
- openapi-typescript-fetch supports middleware whereas this library doesn’t
19
21
22
+
### From openapi-typescript-codegen
23
+
24
+
This library is quite different from [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen)
25
+
20
26
## Contributors
21
27
22
28
This library wouldn’t be possible without all these amazing contributors:
|`params`| ParamsObject | Provide `path` and `query` params from the OpenAPI schema |
33
-
|`params.path`|`{ [name]: value }`| Provide all `path` params (params that are part of the URL) |
34
-
|`params.query`|`{ [name]: value }`| Provide all `query params (params that are part of the <ahref="https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams"target="_blank"rel="noopener noreferrer">searchParams</a> |
35
-
|`body`|`{ [name]:value }`| The <ahref="https://spec.openapis.org/oas/latest.html#request-body-object"target="_blank"rel="noopener noreferrer">requestBody</a> data, if needed (PUT/POST/PATCH/DEL only) |
36
-
|`querySerializer`| QuerySerializer | (optional) Serialize query params for this request only (default: `new URLSearchParams()`) |
37
-
|`bodySerializer`| BodySerializer | (optional) Serialize request body for this request only (default: `JSON.stringify()`) |
38
-
|`parseAs`|`"json"`\|`"text"`\|`"arrayBuffer"`\|`"blob"`\|`"stream"`| Parse the <ahref="https://developer.mozilla.org/en-US/docs/Web/API/Response/body"target="_blank"rel="noopener noreferrer">response body</a>, with `"stream"` skipping processing altogether (default: `"json"`) |
|`params`| ParamsObject | <ahref="https://swagger.io/specification/#parameter-locations"target="_blank"rel="noopener noreferrer">path</a> and <ahref="https://swagger.io/specification/#parameter-locations"target="_blank"rel="noopener noreferrer">query</a> params for the endpoint |
33
+
|`body`|`{ [name]:value }`| <ahref="https://spec.openapis.org/oas/latest.html#request-body-object"target="_blank"rel="noopener noreferrer">requestBody</a> data for the endpoint |
34
+
|`querySerializer`| QuerySerializer | (optional) Provide a [querySerializer](#queryserializer)|
35
+
|`bodySerializer`| BodySerializer | (optional) Provide a [bodySerializer](#bodyserializer)|
36
+
|`parseAs`|`"json"`\|`"text"`\|`"arrayBuffer"`\|`"blob"`\|`"stream"`| (optional) Parse the response using <ahref="https://developer.mozilla.org/en-US/docs/Web/API/Response#instance_methods"target="_blank"rel="noopener noreferrer">a built-in instance method</a> (default: `"json"`). `"stream"` skips parsing altogether and returns the raw stream. |
Similar to [querySerializer](#querySerializer), bodySerializer works for requestBody. You probably only need this when using `multipart/form-data`:
64
+
Similar to [querySerializer](#querySerializer), bodySerializer allows you to customize how the requestBody is serialized if you don’t want the default <ahref="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify"target="_blank">JSON.stringify()</a> behavior. You probably only need this when using `multipart/form-data`:
0 commit comments