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

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

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

Swagger.securityDefinition介绍

暂无

代码示例

代码示例来源:origin: blox/blox

@Override
 public void apply(Swagger swagger) {
  ApiKeyAuthDefinition authorization = new ApiKeyAuthDefinition("Authorization", In.HEADER);
  authorization.setVendorExtension("x-amazon-apigateway-authtype", authType);
  swagger.securityDefinition(SECURITY_SCHEME_NAME, authorization);

  for (Path path : swagger.getPaths().values()) {
   for (Operation operation : path.getOperations()) {
    operation.addSecurity(SECURITY_SCHEME_NAME, Collections.emptyList());
   }
  }
 }
}

代码示例来源:origin: scouter-project/scouter

swagger.securityDefinition("Scouter auth token", new ApiKeyAuthDefinition("Authorization", In.HEADER));
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);

代码示例来源:origin: rakam-io/rakam

.basePath("/")
.tags(ImmutableList.copyOf(tags))
.securityDefinition("write_key", new ApiKeyAuthDefinition().in(In.HEADER).name("write_key"))
.securityDefinition("read_key", new ApiKeyAuthDefinition().in(In.HEADER).name("read_key"))
.securityDefinition("master_key", new ApiKeyAuthDefinition().in(In.HEADER).name("master_key"));

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core

private void addSecuritySchemeToSwaggerDefinition(Swagger swagger, API api) {
  KeyMgtConfigurations keyMgtConfigurations = ServiceReferenceHolder.getInstance().
      getAPIMConfiguration().getKeyManagerConfigs();
  if ((api.getSecurityScheme() & 2) == 2) { //apikey
    log.debug("API security scheme : API Key Scheme");
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey
        (APIMgtConstants.SWAGGER_APIKEY)) {
      swagger.securityDefinition(APIMgtConstants.SWAGGER_APIKEY, new ApiKeyAuthDefinition(
          APIMgtConstants.SWAGGER_APIKEY, In.HEADER));
    }
  }
  if ((api.getSecurityScheme() & 1) == 1) {
    log.debug("API security Scheme : Oauth");
    OAuth2Definition oAuth2Definition = new OAuth2Definition();
    oAuth2Definition = oAuth2Definition.application(keyMgtConfigurations.getTokenEndpoint());
    oAuth2Definition.setScopes(Collections.emptyMap());
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey
        (APIMgtConstants.OAUTH2SECURITY)) {
      swagger.securityDefinition(APIMgtConstants.OAUTH2SECURITY, oAuth2Definition);
    }
  }
}

代码示例来源:origin: wso2/carbon-apimgt

private void addSecuritySchemeToSwaggerDefinition(Swagger swagger, API api) {
  KeyMgtConfigurations keyMgtConfigurations = ServiceReferenceHolder.getInstance().
      getAPIMConfiguration().getKeyManagerConfigs();
  if ((api.getSecurityScheme() & 2) == 2) { //apikey
    log.debug("API security scheme : API Key Scheme");
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey
        (APIMgtConstants.SWAGGER_APIKEY)) {
      swagger.securityDefinition(APIMgtConstants.SWAGGER_APIKEY, new ApiKeyAuthDefinition(
          APIMgtConstants.SWAGGER_APIKEY, In.HEADER));
    }
  }
  if ((api.getSecurityScheme() & 1) == 1) {
    log.debug("API security Scheme : Oauth");
    OAuth2Definition oAuth2Definition = new OAuth2Definition();
    oAuth2Definition = oAuth2Definition.application(keyMgtConfigurations.getTokenEndpoint());
    oAuth2Definition.setScopes(Collections.emptyMap());
    if (swagger.getSecurityDefinitions() == null || !swagger.getSecurityDefinitions().containsKey
        (APIMgtConstants.OAUTH2SECURITY)) {
      swagger.securityDefinition(APIMgtConstants.OAUTH2SECURITY, oAuth2Definition);
    }
  }
}

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

ApiKeyAuthDefinition apiKeyAuth = new ApiKeyAuthDefinition(apiKey.getName(),
    In.forValue(apiKey.getIn() == null ? "header" : apiKey.getIn()));
_swagger.securityDefinition("auth", apiKeyAuth);

代码示例来源:origin: io.github.scouter-project/scouter-webapp

swagger.securityDefinition("Scouter auth token", new ApiKeyAuthDefinition("Authorization", In.HEADER));
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);

代码示例来源:origin: io.swagger/swagger-compat-spec-parser

System.err.println("Warning!  Authorization nickname already in use!");
    } else {
      swagger.securityDefinition(authNickname, oauth2);
      System.err.println("Warning!  Authorization nickname already in use!");
    } else {
      swagger.securityDefinition(authNickname, oauth2);
  swagger.securityDefinition(authNickname, def);
} else if (auth instanceof BasicAuthorization) {
  BasicAuthDefinition def = new BasicAuthDefinition();
  swagger.securityDefinition(authNickname, def);

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

@Test
public void swaggerSerializeTest() {
  final Info info = new Info().version("1.0.0").title("Swagger WebServices REST");
  
  Swagger swagger = new Swagger().info(info).securityDefinition("basicAuth", new BasicAuthDefinition())
      .scheme(Scheme.HTTP).consumes("application/json").produces("application/json");
  
  final Model patientModel = ModelConverters.getInstance().read(Patient.class).get("Patient");
  swagger.addDefinition("Patient", patientModel);
  
  final String swaggerJson = Json.pretty(swagger);
  assertNotNull(swaggerJson);
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

private void initSwagger() {
  final Info info = new Info()
      .version(OpenmrsConstants.OPENMRS_VERSION_SHORT)
      .title("OpenMRS API Docs")
      .description("OpenMRS RESTful API documentation generated by Swagger")
      .contact(new Contact().name("OpenMRS").url("http://openmrs.org"))
      .license(new License().name("MPL-2.0 w/ HD").url("http://openmrs.org/license"));
  
  swagger
      .info(info)
      .host(this.host)
      .basePath(this.basePath)
      .schemes(this.schemes)
      .securityDefinition("basic_auth", new BasicAuthDefinition())
      .security(new SecurityRequirement().requirement("basic_auth"))
      .consumes("application/json")
      .produces("application/json")
      .externalDocs(new ExternalDocs()
          .description("Find more info on REST Module Wiki")
          .url("https://wiki.openmrs.org/x/xoAaAQ"));
}

相关文章