Skip to content

Add openapi-fetch #1098

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

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-git", { "repo": "drwpow/openapi-typescript" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["openapi-typescript-docs"]
}
4 changes: 2 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = {
parserOptions: {
project: ["./tsconfig.json"],
},
extends: ["plugin:prettier/recommended", "eslint:recommended", "plugin:@typescript-eslint/strict"],
plugins: ["@typescript-eslint"],
extends: ["eslint:recommended", "plugin:@typescript-eslint/strict"],
plugins: ["@typescript-eslint", "prettier"],
rules: {
"@typescript-eslint/consistent-indexed-object-style": "off", // sometimes naming keys is more user-friendly
"@typescript-eslint/no-dynamic-delete": "off", // delete is OK
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"printWidth": 120
"printWidth": 240
}
2 changes: 1 addition & 1 deletion docs/src/content/docs/openapi-fetch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Notice **there are no generics, and no manual typing.** Your endpoint’s exact

## Setup

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):
Install this library along with [openapi-typescript](/introduction):

```bash
npm i openapi-fetch
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
"email": "[email protected]"
},
"scripts": {
"lint": "run-p -s lint:openapi-typescript",
"lint": "run-p -s lint:*",
"lint:openapi-fetch": "cd packages/openapi-fetch && npm run lint",
"lint:openapi-typescript": "cd packages/openapi-typescript && npm run lint",
"test": "run-p -s test:openapi-typescript",
"test": "run-p -s test:*",
"test:openapi-fetch": "cd packages/openapi-fetch && npm test",
"test:openapi-typescript": "cd packages/openapi-typescript && npm test"
},
"devDependencies": {
"@changesets/changelog-git": "^0.1.14",
"@changesets/cli": "^2.26.1",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/openapi-fetch/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test/v1.d.ts
test/v1.yaml
69 changes: 69 additions & 0 deletions packages/openapi-fetch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# openapi-fetch

## 0.1.1

### Patch Changes

- 5d1fb7d: Fix bad HTTP method lookup causing polymorphsim

## 0.1.0

### Minor Changes

- f878cd3: Add querySerializer

### Patch Changes

- 22197a1: Add missing type defs for minified build
- ff3174a: Fix type inference bugs
- 4ce3828: Skip parsing JSON for empty responses (#23)
- ff3ae1b: Skip parsing JSON for 204 responses (#28)

## 0.0.8

### Patch Changes

- 8e7cb46: Fix TypeScript lib error, simplify generated types

## 0.0.7

### Patch Changes

- fce1546: Support "application/json;charset=utf-8" content types (#15). Thanks, [@shinzui](https://github.com/shinzui)!
- 0899e0e: Add minified build (#18)

## 0.0.6

### Patch Changes

- 27c149c: Fix data, error sometimes returning undefined

## 0.0.5

### Patch Changes

- c818e65: Export BaseParams shared type (#8)

## 0.0.4

### Patch Changes

- ce99563: Fix optional requestBody in path

## 0.0.3

### Patch Changes

- b69cb51: Autocomplete URLs by path ([#2](https://github.com/drwpow/openapi-fetch/pull/2)). Thanks, [@mitchell-merry](https://github.com/mitchell-merry)!

## 0.0.2

### Patch Changes

- 5a47464: Fix module entry

## 0.0.1

### Patch Changes

- 55d7013: Encode path params
69 changes: 69 additions & 0 deletions packages/openapi-fetch/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Contributing

Thanks for being willing to contribute! 🙏

**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).

## Open issues

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.

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.

## Opening a Pull Request

Pull requests are **welcome** for this repo! Bugfixes will always be accepted, though in some cases some small changes may be requested.

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.

### Setup

1. Install [pnpm](https://pnpm.io/)
2. [Fork this repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and clone your copy locally
3. Run `pnpm i` to install dependencies

### Writing code

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.

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)

### Writing the PR

**Please fill out the template!** It’s a very lightweight template 🙂.

### Changelogs

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:

```
npx changeset
```

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!

### CI

All PRs must fix lint errors, and all tests must pass. PRs will not be merged until all CI checks are “green” (✅).

#### Tests

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.

To run the entire test suite, run:

```bash
npm test
```

To run an individual test:

```bash
npm test -- [partial filename]
```

To start the entire test suite in watch mode:

```bash
npx vitest
```
21 changes: 21 additions & 0 deletions packages/openapi-fetch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Drew Powers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading