Skip to content

Commit

Permalink
add array support for cacheTags
Browse files Browse the repository at this point in the history
  • Loading branch information
omermecitoglu committed Jun 15, 2024
1 parent f111e92 commit 0330327
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@omer-x/next-openapi-interface-generator",
"version": "0.8.1",
"version": "0.9.0",
"description": "OpenAPI interface generator for Next.js",
"keywords": [
"next",
Expand Down
8 changes: 4 additions & 4 deletions src/core/resolvers/operation-param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function resolveOperationParams(operation: OperationObject, method: strin
}
}
if (framework === "next" && method.toUpperCase() === "GET") {
collection.unshift(typescript ? "cacheTag: string | null" : "cacheTag");
collection.unshift(typescript ? "cacheTags: string | string[] | null" : "cacheTags");
}
return collection;
}
Expand Down Expand Up @@ -80,9 +80,9 @@ export function resolveDocParams(operation: OperationObject, method: string, fra
}
if (framework === "next" && method.toUpperCase() === "GET") {
collection.unshift({
name: "cacheTag",
type: "string | null",
description: "Tag name of Next.js fetch cache",
name: "cacheTags",
type: "string | string[] | null",
description: "Tag name(s) of Next.js fetch cache",
});
}
return collection;
Expand Down
4 changes: 2 additions & 2 deletions src/templates/operation-with-form-data.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export async function {{name}}({{parameters}}) {
method: "{{method}}",
body: formData,
{{#if isCacheable}}
cache: cacheTag ? "force-cache" : "no-store",
cache: cacheTags ? "force-cache" : "no-store",
next: {
tags: cacheTag ? [cacheTag] : undefined,
tags: cacheTags ? (Array.isArray(cacheTags) ? cacheTags : [cacheTags]) : undefined,
}
{{/if}}
});
Expand Down
4 changes: 2 additions & 2 deletions src/templates/operation.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export async function {{name}}({{parameters}}) {
body: JSON.stringify(requestBody),
{{/if}}
{{#if isCacheable}}
cache: cacheTag ? "force-cache" : "no-store",
cache: cacheTags ? "force-cache" : "no-store",
next: {
tags: cacheTag ? [cacheTag] : undefined,
tags: cacheTags ? (Array.isArray(cacheTags) ? cacheTags : [cacheTags]) : undefined,
}
{{/if}}
});
Expand Down

0 comments on commit 0330327

Please sign in to comment.