io.swagger.models.Swagger.addSecurityDefinition()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中io.swagger.models.Swagger.addSecurityDefinition()方法的一些代码示例,展示了Swagger.addSecurityDefinition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.addSecurityDefinition()方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:addSecurityDefinition

Swagger.addSecurityDefinition介绍

暂无

代码示例

代码示例来源:origin: io.swagger/swagger-models

public Swagger securityDefinition(String name, SecuritySchemeDefinition securityDefinition) {
  this.addSecurityDefinition(name, securityDefinition);
  return this;
}

代码示例来源:origin: org.kill-bill.billing/killbill-jaxrs

@Override
public void beforeScan(final io.swagger.jaxrs.Reader reader, final Swagger swagger) {
  BasicAuthDefinition basicAuthDefinition = new BasicAuthDefinition();
  swagger.addSecurityDefinition(BASIC_AUTH_SCHEME, basicAuthDefinition);
  ApiKeyAuthDefinition xKillbillApiKey = new ApiKeyAuthDefinition("X-Killbill-ApiKey", In.HEADER);
  swagger.addSecurityDefinition(API_KEY_SCHEME, xKillbillApiKey);
  ApiKeyAuthDefinition xKillbillApiSecret = new ApiKeyAuthDefinition("X-Killbill-ApiSecret", In.HEADER);
  swagger.addSecurityDefinition(API_SECRET_SCHEME, xKillbillApiSecret);
}

代码示例来源:origin: gravitee-io/gravitee-management-rest-api

@Override
  public void afterScan(Reader reader, Swagger swagger) {
    swagger.addSecurityDefinition(TOKEN_AUTH_SCHEME, new BasicAuthDefinition());

    swagger.getPaths().values()
        .stream()
        .forEach(
            path -> path.getOperations()
                .stream()
                .forEach(
                    operation -> operation.addSecurity(GraviteeApiDefinition.TOKEN_AUTH_SCHEME, null)));
  }
}

代码示例来源:origin: io.gravitee.management/gravitee-management-api-rest

@Override
  public void afterScan(Reader reader, Swagger swagger) {
    swagger.addSecurityDefinition(TOKEN_AUTH_SCHEME, new BasicAuthDefinition());

    swagger.getPaths().values()
        .stream()
        .forEach(
            path -> path.getOperations()
                .stream()
                .forEach(
                    operation -> operation.addSecurity(GraviteeApiDefinition.TOKEN_AUTH_SCHEME, null)));
  }
}

代码示例来源:origin: com.gitblit.fathom/fathom-rest-swagger

/**
 * Register authentication security.
 *
 * @param swagger
 * @param operation
 * @param method
 */
protected void registerSecurity(Swagger swagger, Operation operation, Method method) {
  RequireToken requireToken = ClassUtil.getAnnotation(method, RequireToken.class);
  if (requireToken != null) {
    String apiKeyName = requireToken.value();
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey(apiKeyName)) {
      ApiKeyAuthDefinition security = new ApiKeyAuthDefinition();
      security.setName(apiKeyName);
      security.setIn(In.HEADER);
      security.setType("apiKey");
      swagger.addSecurityDefinition(apiKeyName, security);
    }
    operation.addSecurity(apiKeyName, Collections.emptyList());
  }
  BasicAuth basicAuth = ClassUtil.getAnnotation(method, BasicAuth.class);
  if (basicAuth != null) {
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey("basic")) {
      BasicAuthDefinition security = new BasicAuthDefinition();
      swagger.addSecurityDefinition("basic", security);
    }
    operation.addSecurity("basic", Collections.emptyList());
  }
}

代码示例来源:origin: gitblit/fathom

/**
 * Register authentication security.
 *
 * @param swagger
 * @param operation
 * @param method
 */
protected void registerSecurity(Swagger swagger, Operation operation, Method method) {
  RequireToken requireToken = ClassUtil.getAnnotation(method, RequireToken.class);
  if (requireToken != null) {
    String apiKeyName = requireToken.value();
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey(apiKeyName)) {
      ApiKeyAuthDefinition security = new ApiKeyAuthDefinition();
      security.setName(apiKeyName);
      security.setIn(In.HEADER);
      security.setType("apiKey");
      swagger.addSecurityDefinition(apiKeyName, security);
    }
    operation.addSecurity(apiKeyName, Collections.emptyList());
  }
  BasicAuth basicAuth = ClassUtil.getAnnotation(method, BasicAuth.class);
  if (basicAuth != null) {
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey("basic")) {
      BasicAuthDefinition security = new BasicAuthDefinition();
      swagger.addSecurityDefinition("basic", security);
    }
    operation.addSecurity("basic", Collections.emptyList());
  }
}

代码示例来源:origin: FINRAOS/herd

swagger.addSecurityDefinition(securityName, securitySchemeDefinition);

代码示例来源:origin: com.reprezen.genflow/rapidml-swagger

swagger.addSecurityDefinition(it.getName(), this.createSecurityScheme(it));
};
this.getAllUsedSecuritySchemes(model).forEach(_function_5);

代码示例来源:origin: Sayi/swagger-dubbo

swagger.addSecurityDefinition(oAuth2Config.key(), oAuth2Definition);
  apiKeyAuthDefinition.setDescription(apiKeyAuthConfig.description());
  swagger.addSecurityDefinition(apiKeyAuthConfig.key(), apiKeyAuthDefinition);
  swagger.addSecurityDefinition(basicAuthConfig.key(), basicAuthDefinition);

代码示例来源:origin: io.swagger/swagger-jaxrs

swagger.addSecurityDefinition(oAuth2Config.key(), oAuth2Definition);
  apiKeyAuthDefinition.setDescription(apiKeyAuthConfig.description());
  swagger.addSecurityDefinition(apiKeyAuthConfig.key(), apiKeyAuthDefinition);
  swagger.addSecurityDefinition(basicAuthConfig.key(), basicAuthDefinition);

代码示例来源:origin: noboomu/proteus

swagger.addSecurityDefinition(oAuth2Config.key(), oAuth2Definition);
  apiKeyAuthDefinition.setDescription(apiKeyAuthConfig.description());
  swagger.addSecurityDefinition(apiKeyAuthConfig.key(), apiKeyAuthDefinition);
  swagger.addSecurityDefinition(basicAuthConfig.key(), basicAuthDefinition);

代码示例来源:origin: javagossip/dorado

swagger.addSecurityDefinition(oAuth2Config.key(), oAuth2Definition);
  apiKeyAuthDefinition.setDescription(apiKeyAuthConfig.description());
  swagger.addSecurityDefinition(apiKeyAuthConfig.key(), apiKeyAuthDefinition);
  swagger.addSecurityDefinition(basicAuthConfig.key(), basicAuthDefinition);

相关文章