@midwayjs/swagger 3.20.6-beta.1 → 3.20.6-beta.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.
@@ -1,4 +1,4 @@
1
1
  import { SecurityRequirementObject } from '../interfaces';
2
2
  export declare function ApiSecurity(name: string | SecurityRequirementObject, requirements?: string[]): ClassDecorator;
3
- export declare function ApiExcludeSecurity(): MethodDecorator;
3
+ export declare function ApiExcludeSecurity(): ClassDecorator & MethodDecorator;
4
4
  //# sourceMappingURL=api-security.decorator.d.ts.map
@@ -283,7 +283,7 @@ export interface AuthOptions extends Omit<SecuritySchemeObject, 'type'> {
283
283
  /**
284
284
  * 添加全局默认要求
285
285
  */
286
- addSecurityRequirements: boolean;
286
+ addSecurityRequirements?: boolean;
287
287
  }
288
288
  /**
289
289
  * see https://swagger.io/specification/
@@ -221,11 +221,16 @@ let SwaggerExplorer = class SwaggerExplorer {
221
221
  Object.assign(paths[url][webRouter.requestMethod], e.metadata);
222
222
  }
223
223
  }
224
- const excludeSecurity = metaForMethods.find(item => {
225
- return item.key === constants_1.DECORATORS.API_EXCLUDE_SECURITY;
226
- });
224
+ // 检查类和方法上的 ApiExcludeSecurity
225
+ const excludeSecurityClass = metaForClass.find(item => item.key === constants_1.DECORATORS.API_EXCLUDE_SECURITY);
226
+ const excludeSecurityMethod = metaForMethods.find(item => item.key === constants_1.DECORATORS.API_EXCLUDE_SECURITY);
227
+ const excludeSecurity = excludeSecurityClass || excludeSecurityMethod;
227
228
  // 如果存在安全信息,则将其添加到路径中
228
- if (security.length > 0 && !excludeSecurity) {
229
+ if (excludeSecurity) {
230
+ // 显式设置为空数组,覆盖全局 security
231
+ paths[url][webRouter.requestMethod].security = [];
232
+ }
233
+ else if (security.length > 0) {
229
234
  if (!paths[url][webRouter.requestMethod].security) {
230
235
  paths[url][webRouter.requestMethod].security = [];
231
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/swagger",
3
- "version": "3.20.6-beta.1",
3
+ "version": "3.20.6-beta.3",
4
4
  "main": "dist/index.js",
5
5
  "typings": "index.d.ts",
6
6
  "files": [