@velajs/vela 1.8.3 → 1.8.4

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.
@@ -241,6 +241,34 @@ export function createOpenApiDocument(rootModule, options = {}) {
241
241
  }
242
242
  }
243
243
  }
244
+ // Aggregate the document-root `tags` array. NestJS declares tag
245
+ // groups/descriptions/order via `DocumentBuilder().addTag(name, desc)`
246
+ // while its scanner auto-collects operation tags; we wire both halves
247
+ // here. Walk every operation's `tags` in first-seen order (stable: paths
248
+ // insertion order, then verb order), then merge with `options.tags`
249
+ // (caller-declared tags first — preserving their order + descriptions —
250
+ // followed by any purely-collected tag not already declared, as `{ name }`).
251
+ const seenTagNames = new Set();
252
+ const collectedTagNames = [];
253
+ for (const pathItem of Object.values(paths)){
254
+ for (const verb of VERB_WHITELIST){
255
+ const operation = pathItem[verb];
256
+ if (!operation?.tags) continue;
257
+ for (const tagName of operation.tags){
258
+ if (seenTagNames.has(tagName)) continue;
259
+ seenTagNames.add(tagName);
260
+ collectedTagNames.push(tagName);
261
+ }
262
+ }
263
+ }
264
+ const declaredTags = options.tags ?? [];
265
+ const declaredTagNames = new Set(declaredTags.map((t)=>t.name));
266
+ const tags = [
267
+ ...declaredTags,
268
+ ...collectedTagNames.filter((name)=>!declaredTagNames.has(name)).map((name)=>({
269
+ name
270
+ }))
271
+ ];
244
272
  const document = {
245
273
  openapi: '3.1.0',
246
274
  info: {
@@ -258,5 +286,11 @@ export function createOpenApiDocument(rootModule, options = {}) {
258
286
  schemas
259
287
  };
260
288
  }
289
+ // Only attach `tags` when non-empty. Emitting `tags: []` on a tag-less
290
+ // spec is the exact symptom the consumer reported, so omit the key
291
+ // entirely in that case (mirrors the `components` handling above).
292
+ if (tags.length > 0) {
293
+ document.tags = tags;
294
+ }
261
295
  return document;
262
296
  }
@@ -90,6 +90,17 @@ export interface ApiResponseEntry extends ApiResponseOptions {
90
90
  export interface CreateOpenApiDocumentOptions {
91
91
  info?: Partial<OpenApiInfo>;
92
92
  globalPrefix?: string;
93
+ /**
94
+ * Declare top-level tag groups with descriptions and an explicit order
95
+ * (mirrors NestJS `DocumentBuilder().addTag(name, description)`). Tags
96
+ * actually used by operations but NOT declared here are still emitted —
97
+ * appended after the declared ones in first-seen order. Declared tags
98
+ * with no operations are kept (lets you pre-declare ordering/description).
99
+ */
100
+ tags?: Array<{
101
+ name: string;
102
+ description?: string;
103
+ }>;
93
104
  }
94
105
  export interface MountOpenApiOptions {
95
106
  /** Pre-built OpenAPI document to serve. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velajs/vela",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "NestJS-compatible framework for edge runtimes, powered by Hono",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",