feat: add support for ky v2 #3724#3725
Conversation
Remove duplicate ServiceMethods type generation from the NestJS plugin, keeping only ControllerMethods. Simplify the example app by inlining controller logic and removing service layer, guards, and dead code. Add updatePet and deletePet test coverage. Exclude NestJS example and all .gen directories from root ESLint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eScript Scaffolded from `nest new --strict` (NestJS v11), stripped CLI boilerplate, and configured max-strict tsconfig (noUncheckedIndexedAccess, noUnusedLocals, noUnusedParameters, noImplicitReturns, noImplicitOverride, etc.). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unnecessary type casts in pets controller, add ValidationPipe and HttpExceptionFilter to test setup to match production, guard top-level side effect in main.ts, move eslint ignores before rules, and remove unused supertest dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…xample Remove @nestjs/swagger from example and docs — unnecessary for demonstrating the plugin. Upgrade @darraghor/eslint-plugin-nestjs-typed to v7 with flat config support. Extract shared configureApp() factory. Update nest.md to remove stale swagger references and document cookie parameter limitation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Strip DTOs, ValidationPipe, HttpExceptionFilter, and app.factory — none demonstrate the plugin. Controller now uses generated types directly (CreatePetData['body'], UpdatePetData['body']) instead of hand-written DTOs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep only listPets, createPet, showPetById — each demonstrates a distinct plugin pattern (no params, body, path). Drop updatePet/deletePet as they add no new type patterns and distract from the plugin demo. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prepares for TypeScript 7 which removes baseUrl support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move NestJS plugin tests from main test project to packages/openapi-ts-tests/nestjs/ to reduce CI memory pressure during type checking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…n issue The plugin pulls @typescript-eslint@8.57.0 which requires Node ^22.13.0, breaking CI on 22.12.0. Removed along with typescript-eslint and the per-example eslint config - root eslint config covers the example. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: add NestJS plugin
…f string literal
feat: python sdk params
…ator Fix mapped discriminator to self outputting `$type: string` instead of string literal
Fix/spec types
chore: remove package-lock.json files
…ve-preview-7.x chore(deps): update dependency @typescript/native-preview to v7.0.0-dev.20260403.1
|
|
|
Reviewed PR #3725. Found a redundant/dead code path in the error-handling logic at Task list (6/6 completed)
|
|
@atomicpages is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
|
|
TL;DR — Upgrades the Key changes
Summary | 35 files | 2 commits | base: Ky 2 error handling with
|
| import type { HTTPError, Options as KyOptions } from 'ky'; | ||
| import ky from 'ky'; | ||
| import type { Options as KyOptions } from 'ky'; | ||
| import ky, { isHTTPError } from 'ky'; |
There was a problem hiding this comment.
this was available in later version of ky v1, not required to use, but helps with tsc
There was a problem hiding this comment.
Important
Two issues to address: a dead/redundant code path in the error-handling logic, and a personal editor setting that leaked into the diff.
| jsonError = JSON.parse(textError); | ||
| } catch { | ||
| jsonError = undefined; | ||
| if (kyHttpError) { |
There was a problem hiding this comment.
This is due to:
- Make .json() throw on empty bodies and 204 responses instead of returning an empty string (Make
json()throw on empty responses sindresorhus/ky#854) sindresorhus/ky@1b8e1ff - Make beforeError hook receive all errors, not just HTTPError (Make
beforeErrorhook receive all errors sindresorhus/ky#829) sindresorhus/ky@101c74b
| if (error && typeof error === 'object' && 'response' in error) { | ||
| const httpError = error as HTTPError; | ||
| response = httpError.response; | ||
| if (isHTTPError(error)) { |
There was a problem hiding this comment.
This should be safe to use: https://github.com/sindresorhus/ky/blob/7d23d68e2614777f240896060f31d77f74f1a0d2/source/utils/type-guards.ts#L8
There was a problem hiding this comment.
This has already landed in #3806 , you may wanna pull/rebase from the latest branch.
| export const client = createClient( | ||
| createConfig<ClientOptions2>({ baseUrl: 'https://petstore3.swagger.io/api/v3' }), | ||
| ); | ||
| export const client = createClient(createConfig<ClientOptions2>({ baseUrl: '/api/v3' })); |
There was a problem hiding this comment.
Instead of altering the example, maybe you can add a test case?
In my own PR, I added an unit test case with mocked fetch to validate that fetch receives proper credential: include
You can use the similar technique to validate mocked fetch received a proper URL.
|
Acknowledged the author's correction on the truthiness thread — Task list (2/3 completed) |
|
Fixed the bug in the final error branch of Task list (4/4 completed)
|
|
@atomicpages Hello, would you like to resolve the conflict? Some of your changes got landed already in my merged PR #3806 (e.g., prefer There are also other changes as well. I will add a few review comments. |
|
|
||
| Hey API types omit several Ky options that the wrapper sets itself (for example `method`, `body`, and `prefix`). For any other Ky settings, pass them in **`kyOptions`** or on the top-level config where the generated types allow it. | ||
|
|
||
| If you are upgrading from Ky 1, rename **`prefixUrl` to `prefix`** anywhere you pass Ky configuration (including inside `kyOptions`). Ky 2 also adds a standard **`baseUrl`** option for URL resolution; see the [Ky v2.0.0 release notes](https://github.com/sindresorhus/ky/releases/tag/v2.0.0) for hooks, `HTTPError.data`, and other breaking changes. |
There was a problem hiding this comment.
Technically, this is not true.
AFAIK, the current version of client-ky only respects baseUrl from Hey API's own options, and Hey API always uses the buildUrl function to join the full URL, so the Ky instance will always receive a full URL instead of a relative URL.
In short, Ky's prefixUrl option never worked in the current version of client-ky.
| export interface Config<T extends ClientOptions = ClientOptions> | ||
| extends | ||
| Omit<KyOptions, 'body' | 'headers' | 'method' | 'prefixUrl' | 'retry' | 'throwHttpErrors'>, | ||
| Omit<KyOptions, 'body' | 'headers' | 'method' | 'prefix' | 'retry' | 'throwHttpErrors'>, |
There was a problem hiding this comment.
Ky v2 also has baseUrl, isn't it?
https://github.com/sindresorhus/ky#baseurl
Also, it would be nice to still include prefixUrl in the list as well, it would be nice to support both Ky v1 and v2 when possible.
| return parseErrorResponse(response, request, opts, interceptors, { | ||
| bodyConsumed: true, | ||
| data: undefined, | ||
| }); |
There was a problem hiding this comment.
bodyConsumed issue may (or may not) be resolved by my other yet-to-be-merged PR #3814
In that PR, I use a huge try catch block, so any thrown error may not have its body consumed (remains to be seen, though).


Config/kyOptionstypes: omitprefixinstead of removedprefixUrl.HTTPErrorwithisHTTPError, useerror.datawhen Ky has consumed the body, and fall back toresponse.text()when the body is still readable (e.g. tests).dataand a failingresponse.text().openapi-ts-testssnapshots for@hey-api/client-ky; bumpkyto 2.x in the Ky example and test package; regenerate example client output.docs/openapi-ts/clients/ky.mdfor Ky 2,prefixUrl→prefix, andkyOptionsexample.Note: the tests I delegated to cursor. I'm happy to either revert and/or amend any changes. LMK