v4.0.0
Migration
Nuxt 4 Is Required
The module no longer supports Nuxt 3.
openapi-typescript v7 Is Required
The peer dependency used to accept ^5 || ^6 || ^7 and now accepts ^7 alone. Upgrade the package alongside the module and regenerate your schema types.
The experimental Namespace Is Gone
Its four flags moved out and two of them changed their default:
| Before | Now | Default |
|---|---|---|
experimental.enablePrefixedProxy: true |
server.proxyMode: 'passthrough' |
Unchanged |
experimental.disableClientPayloadCache: true |
payloadCache: false |
Unchanged |
experimental.enableAutoKeyInjection: true |
Removed | Always on |
experimental.enableSchemaFileWatcher |
Removed | Always on in dev |
Every useMyApiData call now gets its own async data state, keyed by its position in your source, the way Nuxt keys useFetch and useAsyncData – with no switch either way, as Nuxt has none. Two components asking for the same resource therefore no longer share a data ref, and no longer collide when their transform, pick or default options differ. They do still share the underlying request. Pass the same explicit key to put two call sites back on one instance.
The schema file watcher no longer has a switch. Nuxt's own builder watcher cannot stand in for it – it covers each layer's app and server directories only, and a path registered through nuxt.options.watch restarts the dev server rather than regenerating the types.
refresh() Sends the Request Again
The request cache sits below Nuxt's async data, so Nuxt could not reach into it: refresh(), clear() and a key change driven by a reactive option were answered with the response already cached for that request. Each of them now sends a new request. Expect more traffic where a page refreshes on an interval, and reach for getCachedData to decide when a call site may keep what it has.
cache Only Means the Browser Cache Now
cache used to accept a boolean alongside the RequestInit.cache values, and the boolean drove the payload cache. Payload caching now has its own option:
const { data } = await useMyApiData('posts', {
- cache: false,
+ payloadCache: false
})cache: true and cache: false are compile errors, so they surface on upgrade. One change is silent, though: a string value used to turn payload caching off as a side effect. cache: 'no-store' now only sets the browser cache mode, and the payload cache stays on unless you add payloadCache: false.
The Wrapped Proxy Reports 502 for an Unreachable API
An API that cannot be reached used to yield 503 Service Unavailable from the default proxy and 502 Bad Gateway from the passthrough one. Both report 502 now.
The Passthrough Proxy No Longer Forwards authorization
With server.proxyMode set to 'passthrough', a browser request's authorization header used to travel on to your API. It no longer does: the header carries the caller's credentials for your app, not your app's credentials for the upstream service.
A cookie still travels, but only for endpoints that set cookies: true. Note that the passthrough proxy forwards the request as it stands and does not add the endpoint's token, headers or query – only the default /api/__api_party/{endpointId} handler does. If you relied on the old behavior to pass a bearer token through, attach it in a request hook.
Endpoint Types Resolve Through the Client
Service<Path, Method> used to compute request, response and responses with its own type logic, which disagreed with what the composables returned. Both now resolve through the same helpers, so the type you extract is the type you get back.
Three consequences, all at type level:
- A method the path doesn't declare is now a compile error.
PetStore<'/pet', 'get'>fails where the schema declares onlypostandput; likewisePetStoreApiMethods<'/pet'>narrows from every HTTP verb to'post' | 'put'. - An operation that declares no path or query parameters reports
never, where the old logic answeredundefined, and one that declares no request body reportsundefined, where the old logic answeredunknown. - A status code that carries no response body reports
undefinedinresponses, in place ofRecord<string, never>. So doesresponsefor an operation whose success carries no body –PetStore<'/pet/{petId}', 'delete'>['response']is nownever.
See OpenAPI Type Helpers for what each property now reports.
schema No Longer Accepts a Function
An endpoint's schema takes a file path, a URL or the parsed schema object. Resolve a schema you have to build yourself in the api-party:extend hook instead, which runs at module initialization and can await:
export default defineNuxtConfig({
hooks: {
'api-party:extend': async (options) => {
options.endpoints!.myApi!.schema = await buildSchema()
},
},
})Passing a function was deprecated in v2.1.0 and now throws.
Removed Deprecated Type Helpers
Response, RequestBody and RequestQuery are gone from #nuxt-api-party/{endpointId}. They were keyed by operation ID; the endpoint interface is keyed by path and method, which is what the composables take:
-import type { Response } from '#nuxt-api-party/petStore'
+import type { PetStore } from '#nuxt-api-party'
-type Pet = Response<'getPetById'>
+type Pet = PetStore<'/pet/{petId}', 'get'>['response']RequestBody<'addPet'> becomes PetStore<'/pet', 'post'>['request'], and RequestQuery<'findPetsByStatus'> becomes PetStore<'/pet/findByStatus', 'get'>['query'].
🚨 Breaking Changes
- Withhold client credentials from the prefixed proxy - by @johannschopplich (7d22e)
- Remove the deprecated Response, RequestBody and RequestQuery helpers - by @johannschopplich (2b8ac)
- Resolve endpoint types the way the composables do - by @johannschopplich (b2e33)
- Remove the deprecated function form of the schema option - by @johannschopplich (c338d)
- Require Nuxt 4 - by @johannschopplich (f275a)
- Require openapi-typescript v7 - by @johannschopplich (d2ae6)
- Replace the experimental namespace with stable options - by @johannschopplich (5bd1d)
- Rename the prefixed proxy mode to passthrough - by @johannschopplich (b89bb)
- Key async data per call site without a switch - by @johannschopplich (0ad59)
- Serialize form data as an ordered entry list - by @johannschopplich (14fa4)
🐞 Bug Fixes
- Keep endpoint types resolved under typescript 6 - by @johannschopplich (64c91)
- Stop duplicating the forwarded cookie in the server handler - by @johannschopplich (ab67d)
- Forward the headers option to the API again - by @johannschopplich (4ca53)
- Keep the test run green under vitest typecheck - by @johannschopplich (c6d87)
- Run the docs scripts from the docs workspace - by @johannschopplich (7b16f)
- Filter proxied headers without mutating the raw request - by @johannschopplich (165c7)
- Report an unreachable API as bad gateway in both proxy modes - by @johannschopplich (21bf1)
- Document the payload cache default the data composables actually use - by @johannschopplich (8d58d)
- Keep one payload cache declaration so its hover doc reads straight - by @johannschopplich (44d98)
- Refetch on refresh instead of serving the cached response - by @johannschopplich (7973f)
- Refetch after a changed key instead of answering from the request cache - by @johannschopplich (7dee4)
- openapi: Substitute every occurrence of a path parameter - by @johannschopplich (f887a)
🏎 Performance
- Build the blob's binary string in chunks - by @johannschopplich (ada7f)
- Encode a blob per chunk and decode it in a loop - by @johannschopplich (2960b)
- Hash the request only when the payload cache can answer it - by @johannschopplich (d9265)