next-openapi-gen 0.10.2 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -210,25 +210,25 @@ export async function POST(request: NextRequest) {
210
210
 
211
211
  ## JSDoc Documentation Tags
212
212
 
213
- | Tag | Description |
214
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ |
215
- | `@description` | Endpoint description |
216
- | `@operationId` | Custom operation ID (overrides auto-generated ID) |
217
- | `@pathParams` | Path parameters type/schema |
218
- | `@params` | Query parameters type/schema (use `@queryParams` if you have prettier-plugin-jsdoc conflicts) |
219
- | `@body` | Request body type/schema |
220
- | `@bodyDescription` | Request body description |
221
- | `@response` | Response type/schema with optional code and description (`User`, `201:User`, `User:Description`, `201:User:Description`) |
222
- | `@responseDescription` | Response description |
223
- | `@responseSet` | Override default response set (`public`, `auth`, `none`) |
224
- | `@add` | Add custom response codes (`409:ConflictResponse`, `429`) |
225
- | `@contentType` | Request body content type (`application/json`, `multipart/form-data`) |
226
- | `@auth` | Authorization type (`bearer`, `basic`, `apikey`) |
227
- | `@tag` | Custom tag |
228
- | `@deprecated` | Marks the route as deprecated |
229
- | `@openapi` | Marks the route for inclusion in documentation (if includeOpenApiRoutes is enabled) |
230
- | `@ignore` | Excludes the route from OpenAPI documentation |
231
- | `@method` | HTTP method for Pages Router (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`) - required for Pages Router only |
213
+ | Tag | Description |
214
+ |------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
215
+ | `@description` | Endpoint description |
216
+ | `@operationId` | Custom operation ID (overrides auto-generated ID) |
217
+ | `@pathParams` | Path parameters type/schema |
218
+ | `@params` | Query parameters type/schema (use `@queryParams` if you have prettier-plugin-jsdoc conflicts) |
219
+ | `@body` | Request body type/schema |
220
+ | `@bodyDescription` | Request body description |
221
+ | `@response` | Response type/schema with optional code and description (`User`, `201:User`, `User:Description`, `201:User:Description`) |
222
+ | `@responseDescription` | Response description |
223
+ | `@responseSet` | Override default response set (`public`, `auth`, `none`) |
224
+ | `@add` | Add custom response codes (`409:ConflictResponse`, `429`) |
225
+ | `@contentType` | Request body content type (`application/json`, `multipart/form-data`) |
226
+ | `@auth` | Authorization type (e.g., `bearer`, `basic`, `apikey`, or a custom type) — supports multiple auths using comma separator (e.g., `bearer, CustomType`) |
227
+ | `@tag` | Custom tag |
228
+ | `@deprecated` | Marks the route as deprecated |
229
+ | `@openapi` | Marks the route for inclusion in documentation (if includeOpenApiRoutes is enabled) |
230
+ | `@ignore` | Excludes the route from OpenAPI documentation |
231
+ | `@method` | HTTP method for Pages Router (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`) - required for Pages Router only |
232
232
 
233
233
  ## Pages Router Support 🆕
234
234
 
@@ -2,7 +2,7 @@ import fs from "fs";
2
2
  import traverseModule from "@babel/traverse";
3
3
  const traverse = traverseModule.default || traverseModule;
4
4
  import { HTTP_METHODS } from "./router-strategy.js";
5
- import { parseTypeScriptFile } from "./utils.js";
5
+ import { parseTypeScriptFile, performAuthPresetReplacements } from "./utils.js";
6
6
  export class PagesRouterStrategy {
7
7
  config;
8
8
  constructor(config) {
@@ -169,6 +169,8 @@ export class PagesRouterStrategy {
169
169
  case "apikey":
170
170
  auth = "ApiKeyAuth";
171
171
  break;
172
+ default:
173
+ auth = performAuthPresetReplacements(authValue);
172
174
  }
173
175
  }
174
176
  return {
@@ -250,11 +250,10 @@ export class RouteProcessor {
250
250
  }
251
251
  // Add auth
252
252
  if (auth) {
253
- definition.security = [
254
- {
255
- [auth]: [],
256
- },
257
- ];
253
+ const authItems = auth.split(",").map(item => item.trim());
254
+ definition.security = authItems.map(authItem => ({
255
+ [authItem]: [],
256
+ }));
258
257
  }
259
258
  if (params) {
260
259
  definition.parameters =
package/dist/lib/utils.js CHANGED
@@ -73,6 +73,8 @@ export function extractJSDocComments(path) {
73
73
  case "apikey":
74
74
  auth = "ApiKeyAuth";
75
75
  break;
76
+ default:
77
+ auth = performAuthPresetReplacements(value);
76
78
  }
77
79
  }
78
80
  if (commentValue.includes("@description")) {
@@ -247,6 +249,16 @@ export function cleanSpec(spec) {
247
249
  }
248
250
  return newSpec;
249
251
  }
252
+ const AUTH_PRESET_REPLACEMENTS = {
253
+ bearer: "BearerAuth",
254
+ basic: "BasicAuth",
255
+ apikey: "ApiKeyAuth",
256
+ };
257
+ export function performAuthPresetReplacements(authValue) {
258
+ const authParts = authValue.split(",").map((part) => part.trim());
259
+ const mappedParts = authParts.map((part) => AUTH_PRESET_REPLACEMENTS[part.toLowerCase()] || part);
260
+ return mappedParts.join(",");
261
+ }
250
262
  export function getOperationId(routePath, method) {
251
263
  const operation = routePath.replaceAll(/\//g, "-").replace(/^-/, "");
252
264
  return `${method}-${operation}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-openapi-gen",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Automatically generate OpenAPI 3.0 documentation from Next.js projects, with support for Zod schemas and TypeScript types.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",