Skip to content

Commit

Permalink
Merge branch 'drwpow:main' into fix/converting-by-glob
Browse files Browse the repository at this point in the history
  • Loading branch information
pvanagtmaal authored Aug 9, 2023
2 parents c1fbdae + d93755b commit 43edab3
Show file tree
Hide file tree
Showing 56 changed files with 7,691 additions and 6,700 deletions.
5 changes: 0 additions & 5 deletions .changeset/new-rats-yawn.md

This file was deleted.

2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
rules: {
"@typescript-eslint/consistent-indexed-object-style": "off", // sometimes naming keys is more user-friendly
"@typescript-eslint/no-dynamic-delete": "off", // delete is OK
"@typescript-eslint/no-non-null-assertion": "off", // this is better than "as"
"@typescript-eslint/no-unnecessary-condition": "off", // this gives bad advice
"no-console": "error",
"no-unused-vars": "off",
Expand All @@ -19,6 +20,7 @@ module.exports = {
rules: {
"@typescript-eslint/ban-ts-comment": "off", // allow @ts-ignore only in tests
"@typescript-eslint/no-empty-function": "off", // don’t enforce this in tests
"@typescript-eslint/no-explicit-any": "off", // tests sometimes need this
"no-only-tests/no-only-tests": "error",
"vitest/valid-title": "off", // doesn’t work?
},
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ See the [README](./README.md) for basic setup.

## Corrections / small edits

Corrections are always welcome! Please go straight to [opening a PR](https://github.com/drwpow/openapi-typescript/pulls) for correcting typos or misinformation language. Small edits are also welcome, which include shortening verbose language or clarifying confusing wording.
Corrections are always welcome! Please go straight to [opening a PR](https://github.com/drwpow/openapi-typescript/pulls) for correcting typos or misinformation. Small grammar edits are also welcome such as shortening verbose language or clarifying confusing statements.

## Styling fixes

Expand Down
1 change: 1 addition & 0 deletions docs/scripts/update-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const OPENAPI_TS_CONTRIBUTORS = [
"toomuchdesign",
"psychedelicious",
"tkrotoff",
"pimveldhuisen",
]),
];

Expand Down
2 changes: 1 addition & 1 deletion docs/src/data/contributors.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"del-cli": "^5.0.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vitest": "^0.2.6",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-vitest": "^0.2.8",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"prettier": "^3.0.1",
"typescript": "^5.1.6"
}
}
6 changes: 6 additions & 0 deletions packages/openapi-fetch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# openapi-fetch

## 0.7.2

### Patch Changes

- [#1242](https://github.com/drwpow/openapi-typescript/pull/1242) [`8d11701`](https://github.com/drwpow/openapi-typescript/commit/8d11701deb22d47bc8ef04b6210ea6722ecb461b) Thanks [@drwpow](https://github.com/drwpow)! - Fix impossible body typing

## 0.7.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-fetch/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Thanks for being willing to contribute! 🙏

## 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.
Please check out the [the open issues](https://github.com/drwpow/openapi-typescript/issues). Issues labelled [**Good First Issue**](https://github.com/drwpow/openapi-typescript/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)are especially good to start 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.

Expand All @@ -26,7 +26,7 @@ However, if adding a feature or breaking change, please **open an issue first to

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)
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. Clarity is favored over strict rules. Changelogs are generated separately from git (see [the Changelogs section](#changelogs))

### Writing the PR

Expand Down
7 changes: 3 additions & 4 deletions packages/openapi-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "openapi-fetch",
"description": "Fetch using your OpenAPI types. Weighs 2 kb and has virtually zero runtime. Works with React, Vue, Svelte, or vanilla JS.",
"version": "0.7.1",
"version": "0.7.2",
"author": {
"name": "Drew Powers",
"email": "[email protected]"
Expand Down Expand Up @@ -59,10 +59,9 @@
},
"devDependencies": {
"del-cli": "^5.0.0",
"esbuild": "^0.18.17",
"esbuild": "^0.19.0",
"nanostores": "^0.9.3",
"openapi-typescript": "*",
"prettier": "^2.8.8",
"openapi-typescript": "^6.4.2",
"typescript": "^5.1.6",
"vitest": "^0.33.0",
"vitest-fetch-mock": "^0.2.2"
Expand Down
16 changes: 8 additions & 8 deletions packages/openapi-fetch/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe("client", () => {

// expect error on missing `body`
// @ts-expect-error
await client.GET("/blogposts", {});
await client.PUT("/blogposts", {});

// expect error on missing fields
// @ts-expect-error
Expand Down Expand Up @@ -318,7 +318,7 @@ describe("client", () => {
new Headers({
...headers, // assert new header got passed
"Content-Type": "application/json", // probably doesn’t need to get tested, but this was simpler than writing lots of code to ignore these
})
}),
);
});

Expand All @@ -333,7 +333,7 @@ describe("client", () => {
new Headers({
"Cache-Control": "no-cache",
"Content-Type": "application/json",
})
}),
);
});

Expand Down Expand Up @@ -372,7 +372,7 @@ describe("client", () => {
it("multipart/form-data", async () => {
const client = createClient<paths>();
mockFetchOnce({ status: 200, body: "{}" });
const { data } = await client.PUT("/contact", {
await client.PUT("/contact", {
body: {
name: "John Doe",
email: "[email protected]",
Expand Down Expand Up @@ -401,9 +401,8 @@ describe("client", () => {
it("returns empty object on 204", async () => {
const client = createClient<paths>();
mockFetchOnce({ status: 204, body: "" });
const { data, error, response } = await client.PUT("/tag/{name}", {
const { data, error, response } = await client.DELETE("/tag/{name}", {
params: { path: { name: "New Tag" } },
body: { description: "This is a new tag" },
});

// assert correct data was returned
Expand Down Expand Up @@ -445,6 +444,7 @@ describe("client", () => {
const client = createClient<paths>();
mockFetchOnce({ status: 200, body: "{}" });
const { data } = await client.GET("/anyMethod", { parseAs: "blob" });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((data as any).constructor.name).toBe("Blob");
});

Expand Down Expand Up @@ -681,7 +681,7 @@ describe("examples", () => {
setTimeout(() => {
token.set(tokenVal); // simulate promise-like token setting
resolve();
}, 0)
}, 0),
);
await client.get().GET("/blogposts/{post_id}", { params: { path: { post_id: "1234" } } });
expect(fetchMocker.mock.calls[1][1].headers.get("authorization")).toBe(`Bearer ${tokenVal}`);
Expand Down Expand Up @@ -710,7 +710,7 @@ describe("examples", () => {
setTimeout(() => {
token = tokenVal; // simulate promise-like token setting
resolve();
}, 0)
}, 0),
);
await client.GET("/blogposts/{post_id}", { params: { path: { post_id: "1234" } } });
expect(fetchMocker.mock.calls[1][1].headers.get("authorization")).toBe(`Bearer ${tokenVal}`);
Expand Down
6 changes: 5 additions & 1 deletion packages/openapi-fetch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const DEFAULT_HEADERS = {
};
const TRAILING_SLASH_RE = /\/*$/;

// Note: though "any" is considered bad practice in general, this library relies
// on "any" for type inference only it can give. Same goes for the "{}" type.
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */

/** options for each client instance */
interface ClientOptions extends RequestInit {
/** set the common root URL for all API requests */
Expand Down Expand Up @@ -47,7 +51,7 @@ export type Params<T> = T extends { parameters: any } ? { params: NonNullable<T[
export type RequestBodyObj<T> = T extends { requestBody?: any } ? T["requestBody"] : never;
export type RequestBodyContent<T> = undefined extends RequestBodyObj<T> ? FilterKeys<NonNullable<RequestBodyObj<T>>, "content"> | undefined : FilterKeys<RequestBodyObj<T>, "content">;
export type RequestBodyMedia<T> = FilterKeys<RequestBodyContent<T>, MediaType> extends never ? FilterKeys<NonNullable<RequestBodyContent<T>>, MediaType> | undefined : FilterKeys<RequestBodyContent<T>, MediaType>;
export type RequestBody<T> = undefined extends RequestBodyMedia<T> ? { body?: RequestBodyMedia<T> } : { body: RequestBodyMedia<T> };
export type RequestBody<T> = RequestBodyMedia<T> extends never ? { body?: never } : undefined extends RequestBodyMedia<T> ? { body?: RequestBodyMedia<T> } : { body: RequestBodyMedia<T> };
export type QuerySerializer<T> = (query: T extends { parameters: any } ? NonNullable<T["parameters"]["query"]> : Record<string, unknown>) => string;
export type BodySerializer<T> = (body: RequestBodyMedia<T>) => any;
export type RequestOptions<T> = Params<T> &
Expand Down
12 changes: 12 additions & 0 deletions packages/openapi-fetch/test/v1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ export interface paths {
500: components["responses"]["Error"];
};
};
delete: {
parameters: {
path: {
name: string;
};
};
responses: {
/** @description No Content */
204: never;
500: components["responses"]["Error"];
};
};
parameters: {
path: {
name: string;
Expand Down
6 changes: 6 additions & 0 deletions packages/openapi-fetch/test/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ paths:
$ref: '#/components/responses/CreateTag'
500:
$ref: '#/components/responses/Error'
delete:
responses:
204:
description: No Content
500:
$ref: '#/components/responses/Error'
/default-as-error:
get:
responses:
Expand Down
18 changes: 18 additions & 0 deletions packages/openapi-typescript/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# openapi-typescript

## 6.4.3

### Patch Changes

- [#1287](https://github.com/drwpow/openapi-typescript/pull/1287) [`8a9d8ed`](https://github.com/drwpow/openapi-typescript/commit/8a9d8ede95802370c4015846a4856fd0701ada33) Thanks [@drwpow](https://github.com/drwpow)! - Fix oneOf handling with empty object parent type

## 6.4.2

### Patch Changes

- [#1278](https://github.com/drwpow/openapi-typescript/pull/1278) [`d7420e3`](https://github.com/drwpow/openapi-typescript/commit/d7420e30f1697ad8cfc0fdefc93127ad2b813f99) Thanks [@pvanagtmaal](https://github.com/pvanagtmaal)! - Fix externalizing external refs

## 6.4.1

### Patch Changes

- [#1269](https://github.com/drwpow/openapi-typescript/pull/1269) [`e735ff2`](https://github.com/drwpow/openapi-typescript/commit/e735ff2b9307eaec1959d0d3bf733a240a880c48) Thanks [@pimveldhuisen](https://github.com/pimveldhuisen)! - Stop trimming whitespace other than linebreaks in string values

## 6.4.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi-typescript/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Thanks for being willing to contribute! 🙏

## Open issues

Please check out the [the open issues](https://github.com/drwpow/openapi-typescript/issues). Issues labelled [**Help Wanted**](https://github.com/drwpow/openapi-typescript/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) and [**Good First Issue**](https://github.com/drwpow/openapi-typescript/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) are especially good to help with.
Please check out the [the open issues](https://github.com/drwpow/openapi-typescript/issues). Issues labelled [**Good First Issue**](https://github.com/drwpow/openapi-typescript/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)are especially good to start 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.

Expand All @@ -26,7 +26,7 @@ However, if adding a feature or breaking change, please **open an issue first to

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)
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. Clarity is favored over strict rules. Changelogs are generated separately from git (see [the Changelogs section](#changelogs))

When working locally, run:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_alert_create
operationId: uptime_create_alert

summary: Create a New Alert

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_check_create
operationId: uptime_create_check

summary: Create a New Check

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_alert_delete
operationId: uptime_delete_alert

summary: Delete an Alert

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_check_delete
operationId: uptime_delete_check

summary: Delete a Check

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_alert_get
operationId: uptime_get_alert

summary: Retrieve an Existing Alert

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_check_get
operationId: uptime_get_check

summary: Retrieve an Existing Check

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_check_state_get
operationId: uptime_get_checkState

summary: Retrieve Check State

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_check_alerts_list
operationId: uptime_list_alerts

summary: List All Alerts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_checks_list
operationId: uptime_list_checks

summary: List All Checks

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_alert_update
operationId: uptime_update_alert

summary: Update an Alert

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
operationId: uptime_check_update
operationId: uptime_update_check

summary: Update a Check

Expand Down
Loading

0 comments on commit 43edab3

Please sign in to comment.