Skip to content

Commit e9898ec

Browse files
authored
Add openapi-fetch (openapi-ts#1098)
1 parent 264b16d commit e9898ec

33 files changed

+2758
-456
lines changed

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": ["@changesets/changelog-git", { "repo": "drwpow/openapi-typescript" }],
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": ["openapi-typescript-docs"]
11+
}

.eslintrc.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = {
44
parserOptions: {
55
project: ["./tsconfig.json"],
66
},
7-
extends: ["plugin:prettier/recommended", "eslint:recommended", "plugin:@typescript-eslint/strict"],
8-
plugins: ["@typescript-eslint"],
7+
extends: ["eslint:recommended", "plugin:@typescript-eslint/strict"],
8+
plugins: ["@typescript-eslint", "prettier"],
99
rules: {
1010
"@typescript-eslint/consistent-indexed-object-style": "off", // sometimes naming keys is more user-friendly
1111
"@typescript-eslint/no-dynamic-delete": "off", // delete is OK

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"printWidth": 120
2+
"printWidth": 240
33
}

docs/src/content/docs/openapi-fetch/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Notice **there are no generics, and no manual typing.** Your endpoint’s exact
4848

4949
## Setup
5050

51-
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, install this library and [openapi-typescript](/introduction):
51+
Install this library along with [openapi-typescript](/introduction):
5252

5353
```bash
5454
npm i openapi-fetch

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
"email": "[email protected]"
99
},
1010
"scripts": {
11-
"lint": "run-p -s lint:openapi-typescript",
11+
"lint": "run-p -s lint:*",
1212
"lint:openapi-fetch": "cd packages/openapi-fetch && npm run lint",
1313
"lint:openapi-typescript": "cd packages/openapi-typescript && npm run lint",
14-
"test": "run-p -s test:openapi-typescript",
14+
"test": "run-p -s test:*",
1515
"test:openapi-fetch": "cd packages/openapi-fetch && npm test",
1616
"test:openapi-typescript": "cd packages/openapi-typescript && npm test"
1717
},
1818
"devDependencies": {
19+
"@changesets/changelog-git": "^0.1.14",
20+
"@changesets/cli": "^2.26.1",
1921
"eslint": "^8.40.0",
2022
"eslint-config-prettier": "^8.8.0",
2123
"eslint-plugin-prettier": "^4.2.1",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test/v1.d.ts
2+
test/v1.yaml

packages/openapi-fetch/CHANGELOG.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# openapi-fetch
2+
3+
## 0.1.1
4+
5+
### Patch Changes
6+
7+
- 5d1fb7d: Fix bad HTTP method lookup causing polymorphsim
8+
9+
## 0.1.0
10+
11+
### Minor Changes
12+
13+
- f878cd3: Add querySerializer
14+
15+
### Patch Changes
16+
17+
- 22197a1: Add missing type defs for minified build
18+
- ff3174a: Fix type inference bugs
19+
- 4ce3828: Skip parsing JSON for empty responses (#23)
20+
- ff3ae1b: Skip parsing JSON for 204 responses (#28)
21+
22+
## 0.0.8
23+
24+
### Patch Changes
25+
26+
- 8e7cb46: Fix TypeScript lib error, simplify generated types
27+
28+
## 0.0.7
29+
30+
### Patch Changes
31+
32+
- fce1546: Support "application/json;charset=utf-8" content types (#15). Thanks, [@shinzui](https://github.com/shinzui)!
33+
- 0899e0e: Add minified build (#18)
34+
35+
## 0.0.6
36+
37+
### Patch Changes
38+
39+
- 27c149c: Fix data, error sometimes returning undefined
40+
41+
## 0.0.5
42+
43+
### Patch Changes
44+
45+
- c818e65: Export BaseParams shared type (#8)
46+
47+
## 0.0.4
48+
49+
### Patch Changes
50+
51+
- ce99563: Fix optional requestBody in path
52+
53+
## 0.0.3
54+
55+
### Patch Changes
56+
57+
- b69cb51: Autocomplete URLs by path ([#2](https://github.com/drwpow/openapi-fetch/pull/2)). Thanks, [@mitchell-merry](https://github.com/mitchell-merry)!
58+
59+
## 0.0.2
60+
61+
### Patch Changes
62+
63+
- 5a47464: Fix module entry
64+
65+
## 0.0.1
66+
67+
### Patch Changes
68+
69+
- 55d7013: Encode path params
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Contributing
2+
3+
Thanks for being willing to contribute! 🙏
4+
5+
**Working on your first Pull Request (PR)?** [Egghead has a great free video introduction](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
6+
7+
## Open issues
8+
9+
Please check out the [the open issues](https://github.com/drwpow/openapi-fetch/issues). Issues labelled [**Help Wanted**](https://github.com/drwpow/openapi-fetch/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) and [**Good First Issue**](https://github.com/drwpow/openapi-fetch/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) are especially good to help with.
10+
11+
Contributing doesn’t have to be in code! Simply answering questions in open issues, or providing workarounds, is just as important a contribution as making pull requests.
12+
13+
## Opening a Pull Request
14+
15+
Pull requests are **welcome** for this repo! Bugfixes will always be accepted, though in some cases some small changes may be requested.
16+
17+
However, if adding a feature or breaking change, please **open an issue first to discuss.** This ensures no time or work is wasted writing code that won’t be accepted to the project (see [Project Goals](./README.md#-project-goals)). Undiscussed feature work may be rejected at the discretion of the maintainers.
18+
19+
### Setup
20+
21+
1. Install [pnpm](https://pnpm.io/)
22+
2. [Fork this repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and clone your copy locally
23+
3. Run `pnpm i` to install dependencies
24+
25+
### Writing code
26+
27+
Create a new branch for your PR with `git checkout -b your-branch-name`. Add the relevant code as well as docs and tests. When you push everything up (`git push`), navigate back to your repo GitHub and you should see a prompt to open a new PR.
28+
29+
While best practices for commit messages are encouraged (e.g. start with an imperative verb, keep it short, use the body if needed), this repo doesn’t follow any specific guidelines like [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). Clarity is favored over strict rules. Changelogs are generated separately from git (see [the Changelogs section](#changelogs)
30+
31+
### Writing the PR
32+
33+
**Please fill out the template!** It’s a very lightweight template 🙂.
34+
35+
### Changelogs
36+
37+
The changelog is generated via [changesets](https://github.com/changesets/changesets), and is separate from Git commit messages and pull request titles. To write a human-readable changelog for your changes, run:
38+
39+
```
40+
npx changeset
41+
```
42+
43+
This will ask if it’s a `patch`, `minor`, or `major` change ([semver](https://semver.org/)), along with a plain description of what you did. Commit this new file along with the rest of your PR, and during the next release this will go into the official changelog!
44+
45+
### CI
46+
47+
All PRs must fix lint errors, and all tests must pass. PRs will not be merged until all CI checks are “green” (✅).
48+
49+
#### Tests
50+
51+
This library uses [Vitest](https://vitest.dev/) for testing. There’s a great [VS Code extension](https://marketplace.visualstudio.com/items?itemName=ZixuanChen.vitest-explorer) you can optionally use if you’d like in-editor debugging tools.
52+
53+
To run the entire test suite, run:
54+
55+
```bash
56+
npm test
57+
```
58+
59+
To run an individual test:
60+
61+
```bash
62+
npm test -- [partial filename]
63+
```
64+
65+
To start the entire test suite in watch mode:
66+
67+
```bash
68+
npx vitest
69+
```

packages/openapi-fetch/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Drew Powers
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)