nestjs-openapi-next 1.0.2 → 1.0.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.
@@ -0,0 +1,70 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <HTMLCodeStyleSettings>
4
+ <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
5
+ </HTMLCodeStyleSettings>
6
+ <JSCodeStyleSettings version="0">
7
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
8
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
9
+ <option name="FORCE_QUOTE_STYlE" value="true" />
10
+ <option name="ENFORCE_TRAILING_COMMA" value="Remove" />
11
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
12
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
13
+ </JSCodeStyleSettings>
14
+ <JetCodeStyleSettings>
15
+ <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
16
+ </JetCodeStyleSettings>
17
+ <TypeScriptCodeStyleSettings version="0">
18
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
19
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
20
+ <option name="FORCE_QUOTE_STYlE" value="true" />
21
+ <option name="ENFORCE_TRAILING_COMMA" value="Remove" />
22
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
23
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
24
+ </TypeScriptCodeStyleSettings>
25
+ <VueCodeStyleSettings>
26
+ <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
27
+ <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
28
+ </VueCodeStyleSettings>
29
+ <codeStyleSettings language="HTML">
30
+ <option name="SOFT_MARGINS" value="80" />
31
+ <indentOptions>
32
+ <option name="INDENT_SIZE" value="2" />
33
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
34
+ <option name="TAB_SIZE" value="2" />
35
+ </indentOptions>
36
+ </codeStyleSettings>
37
+ <codeStyleSettings language="JAVA">
38
+ <indentOptions>
39
+ <option name="USE_TAB_CHARACTER" value="true" />
40
+ <option name="SMART_TABS" value="true" />
41
+ </indentOptions>
42
+ </codeStyleSettings>
43
+ <codeStyleSettings language="JavaScript">
44
+ <option name="SOFT_MARGINS" value="80" />
45
+ <indentOptions>
46
+ <option name="INDENT_SIZE" value="2" />
47
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
48
+ <option name="TAB_SIZE" value="2" />
49
+ </indentOptions>
50
+ </codeStyleSettings>
51
+ <codeStyleSettings language="TypeScript">
52
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
53
+ <option name="SOFT_MARGINS" value="80" />
54
+ <indentOptions>
55
+ <option name="INDENT_SIZE" value="2" />
56
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
57
+ <option name="TAB_SIZE" value="2" />
58
+ </indentOptions>
59
+ </codeStyleSettings>
60
+ <codeStyleSettings language="Vue">
61
+ <option name="SOFT_MARGINS" value="80" />
62
+ <indentOptions>
63
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
64
+ </indentOptions>
65
+ </codeStyleSettings>
66
+ <codeStyleSettings language="kotlin">
67
+ <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
68
+ </codeStyleSettings>
69
+ </code_scheme>
70
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="TypeScriptCompiler">
4
+ <option name="useServicePoweredTypesEnabledManually" value="true" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Ask2AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EditMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,13 @@
1
+ .idea
2
+ .vscode
3
+ node_modules/
4
+ dist/
5
+ vendor/
6
+ cache/
7
+ .*/
8
+ *.min.*
9
+ *.test.*
10
+ *.spec.*
11
+ *.bundle.*
12
+ *.bundle-min.*
13
+ *.log
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/nestjs-openapi-next.iml" filepath="$PROJECT_DIR$/.idea/nestjs-openapi-next.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PrettierConfiguration">
4
+ <option name="myConfigurationMode" value="AUTOMATIC" />
5
+ </component>
6
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -3,6 +3,8 @@ import { HttpServer } from '@nestjs/common/interfaces/http/http-server.interface
3
3
  import { OpenAPIObject, SwaggerCustomOptions, SwaggerDocumentOptions } from './interfaces';
4
4
  export declare class SwaggerModule {
5
5
  private static readonly metadataLoader;
6
+ private static readonly HTTP_METHODS;
7
+ private static collectOperationTagNames;
6
8
  private static mergeWebhooks;
7
9
  private static mergeTags;
8
10
  private static buildXTagGroups;
@@ -320,13 +320,50 @@ function normalizeNullableForOas31(document) {
320
320
  }
321
321
  }
322
322
  class SwaggerModule {
323
+ static collectOperationTagNames(paths, webhooks) {
324
+ const names = [];
325
+ const seen = new Set();
326
+ const collectFromItems = (items) => {
327
+ if (!items) {
328
+ return;
329
+ }
330
+ for (const pathItem of Object.values(items)) {
331
+ if (!pathItem || typeof pathItem !== 'object') {
332
+ continue;
333
+ }
334
+ for (const [key, operation] of Object.entries(pathItem)) {
335
+ if (!SwaggerModule.HTTP_METHODS.has(String(key).toLowerCase())) {
336
+ continue;
337
+ }
338
+ const tags = operation === null || operation === void 0 ? void 0 : operation.tags;
339
+ if (!Array.isArray(tags)) {
340
+ continue;
341
+ }
342
+ for (const t of tags) {
343
+ if (typeof t !== 'string') {
344
+ continue;
345
+ }
346
+ const trimmed = t.trim();
347
+ if (!trimmed || seen.has(trimmed)) {
348
+ continue;
349
+ }
350
+ seen.add(trimmed);
351
+ names.push(trimmed);
352
+ }
353
+ }
354
+ }
355
+ };
356
+ collectFromItems(paths);
357
+ collectFromItems(webhooks);
358
+ return names;
359
+ }
323
360
  static mergeWebhooks(configWebhooks, scannedWebhooks) {
324
361
  if (!configWebhooks && !scannedWebhooks) {
325
362
  return undefined;
326
363
  }
327
364
  return (0, assign_two_levels_deep_1.assignTwoLevelsDeep)({}, configWebhooks || {}, scannedWebhooks || {});
328
365
  }
329
- static mergeTags(configTags, scannedTags) {
366
+ static mergeTags(configTags, scannedTags, operationTagNames) {
330
367
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
331
368
  const byName = new Map();
332
369
  for (const tag of configTags || []) {
@@ -353,6 +390,14 @@ class SwaggerModule {
353
390
  merged.kind = (_j = existing.kind) !== null && _j !== void 0 ? _j : tag.kind;
354
391
  byName.set(tag.name, merged);
355
392
  }
393
+ if (byName.size > 0) {
394
+ for (const name of operationTagNames || []) {
395
+ if (!name || byName.has(name)) {
396
+ continue;
397
+ }
398
+ byName.set(name, { name });
399
+ }
400
+ }
356
401
  const merged = [...byName.values()];
357
402
  return merged.length > 0 ? merged : undefined;
358
403
  }
@@ -410,7 +455,8 @@ class SwaggerModule {
410
455
  const swaggerScanner = new swagger_scanner_1.SwaggerScanner();
411
456
  const document = swaggerScanner.scanApplication(app, options);
412
457
  document.components = (0, assign_two_levels_deep_1.assignTwoLevelsDeep)({}, config.components, document.components);
413
- const mergedTags = SwaggerModule.mergeTags(config.tags, document.tags);
458
+ const operationTagNames = SwaggerModule.collectOperationTagNames(document.paths, document.webhooks);
459
+ const mergedTags = SwaggerModule.mergeTags(config.tags, document.tags, operationTagNames);
414
460
  const mergedWebhooks = SwaggerModule.mergeWebhooks(config.webhooks, document.webhooks);
415
461
  const mergedDocument = Object.assign(Object.assign(Object.assign(Object.assign({ openapi: '3.0.0', paths: {} }, config), document), (mergedTags ? { tags: mergedTags } : {})), (mergedWebhooks ? { webhooks: mergedWebhooks } : {}));
416
462
  if (isOas31OrAbove(mergedDocument.openapi)) {
@@ -590,3 +636,13 @@ class SwaggerModule {
590
636
  }
591
637
  exports.SwaggerModule = SwaggerModule;
592
638
  SwaggerModule.metadataLoader = new metadata_loader_1.MetadataLoader();
639
+ SwaggerModule.HTTP_METHODS = new Set([
640
+ 'get',
641
+ 'put',
642
+ 'post',
643
+ 'delete',
644
+ 'options',
645
+ 'head',
646
+ 'patch',
647
+ 'trace'
648
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-openapi-next",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A fork of @nestjs/swagger support OAS 3.2",
5
5
  "author": "undownding",
6
6
  "license": "MIT",
@@ -1,25 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "WebSearch",
5
- "WebFetch(domain:spec.openapis.org)",
6
- "WebFetch(domain:www.openapis.org)",
7
- "WebFetch(domain:blog.stoplight.io)",
8
- "WebFetch(domain:apisyouwonthate.com)",
9
- "WebFetch(domain:github.com)",
10
- "Bash(gh auth status:*)",
11
- "Bash(gh issue create:*)",
12
- "Bash(gh issue view:*)",
13
- "Bash(gh issue edit:*)",
14
- "Bash(npm test)",
15
- "Bash(npm install)",
16
- "Bash(npm test:*)",
17
- "Bash(gh pr view:*)",
18
- "Bash(git checkout:*)",
19
- "Bash(git add:*)",
20
- "Bash(git commit -m \"$\\(cat <<''EOF''\ndocs: update README with OAS 3.1/3.2 features\n\nAdd documentation for newly implemented OpenAPI 3.1/3.2 features:\n- JSON Schema Draft 2020-12 alignment\n- type as array support \\(replaces nullable\\)\n- LicenseObject.identifier\n- ServerObject.pathPrefix\n- InfoObject.tags\n- ReferenceObject summary/description override\n- exclusiveMinimum/exclusiveMaximum type change\n\nCloses #7\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
21
- "Bash(git push:*)",
22
- "Bash(gh pr create:*)"
23
- ]
24
- }
25
- }