Skip to content

Commit 0330327

Browse files
committed
add array support for cacheTags
1 parent f111e92 commit 0330327

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@omer-x/next-openapi-interface-generator",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "OpenAPI interface generator for Next.js",
55
"keywords": [
66
"next",

src/core/resolvers/operation-param.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function resolveOperationParams(operation: OperationObject, method: strin
4848
}
4949
}
5050
if (framework === "next" && method.toUpperCase() === "GET") {
51-
collection.unshift(typescript ? "cacheTag: string | null" : "cacheTag");
51+
collection.unshift(typescript ? "cacheTags: string | string[] | null" : "cacheTags");
5252
}
5353
return collection;
5454
}
@@ -80,9 +80,9 @@ export function resolveDocParams(operation: OperationObject, method: string, fra
8080
}
8181
if (framework === "next" && method.toUpperCase() === "GET") {
8282
collection.unshift({
83-
name: "cacheTag",
84-
type: "string | null",
85-
description: "Tag name of Next.js fetch cache",
83+
name: "cacheTags",
84+
type: "string | string[] | null",
85+
description: "Tag name(s) of Next.js fetch cache",
8686
});
8787
}
8888
return collection;

src/templates/operation-with-form-data.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export async function {{name}}({{parameters}}) {
1111
method: "{{method}}",
1212
body: formData,
1313
{{#if isCacheable}}
14-
cache: cacheTag ? "force-cache" : "no-store",
14+
cache: cacheTags ? "force-cache" : "no-store",
1515
next: {
16-
tags: cacheTag ? [cacheTag] : undefined,
16+
tags: cacheTags ? (Array.isArray(cacheTags) ? cacheTags : [cacheTags]) : undefined,
1717
}
1818
{{/if}}
1919
});

src/templates/operation.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export async function {{name}}({{parameters}}) {
99
body: JSON.stringify(requestBody),
1010
{{/if}}
1111
{{#if isCacheable}}
12-
cache: cacheTag ? "force-cache" : "no-store",
12+
cache: cacheTags ? "force-cache" : "no-store",
1313
next: {
14-
tags: cacheTag ? [cacheTag] : undefined,
14+
tags: cacheTags ? (Array.isArray(cacheTags) ? cacheTags : [cacheTags]) : undefined,
1515
}
1616
{{/if}}
1717
});

0 commit comments

Comments
 (0)