本文整理汇总了Java中io.swagger.util.ReflectionUtils.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtils.getAnnotation方法的具体用法?Java ReflectionUtils.getAnnotation怎么用?Java ReflectionUtils.getAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.util.ReflectionUtils
的用法示例。
在下文中一共展示了ReflectionUtils.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyConsumes
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public void applyConsumes(ReaderContext context, Operation operation, Method method) {
final List<String> consumes = new ArrayList<String>();
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null) {
consumes.addAll(parseStringValues(apiOperation.consumes()));
}
if (consumes.isEmpty()) {
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
if (apiAnnotation != null) {
consumes.addAll(parseStringValues(apiAnnotation.consumes()));
}
consumes.addAll(context.getParentConsumes());
}
for (String consume : consumes) {
operation.consumes(consume);
}
}
示例2: applyProduces
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public void applyProduces(ReaderContext context, Operation operation, Method method) {
final List<String> produces = new ArrayList<String>();
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null) {
produces.addAll(parseStringValues(apiOperation.produces()));
}
if (produces.isEmpty()) {
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
if (apiAnnotation != null) {
produces.addAll(parseStringValues(apiAnnotation.produces()));
}
produces.addAll(context.getParentProduces());
}
for (String produce : produces) {
operation.produces(produce);
}
}
示例3: applySecurityRequirements
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
public void applySecurityRequirements(ReaderContext context, Operation operation, Method method) {
final List<SecurityRequirement> securityRequirements = new ArrayList<SecurityRequirement>();
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
if (apiOperation != null) {
securityRequirements.addAll(parseAuthorizations(apiOperation.authorizations()));
}
if (securityRequirements.isEmpty() && apiAnnotation != null) {
securityRequirements.addAll(parseAuthorizations(apiAnnotation.authorizations()));
}
for (SecurityRequirement securityRequirement : securityRequirements) {
operation.security(securityRequirement);
}
}
示例4: applySchemes
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public void applySchemes(ReaderContext context, Operation operation, Method method) {
final List<Scheme> schemes = new ArrayList<Scheme>();
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
if (apiOperation != null) {
schemes.addAll(parseSchemes(apiOperation.protocols()));
}
if (schemes.isEmpty() && apiAnnotation != null) {
schemes.addAll(parseSchemes(apiAnnotation.protocols()));
}
for (Scheme scheme : schemes) {
operation.scheme(scheme);
}
}
示例5: applyConsumes
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
public void applyConsumes(ReaderContext context, Operation operation, Method method) {
final List<String> consumes = new ArrayList<String>();
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null) {
consumes.addAll(parseStringValues(apiOperation.consumes()));
}
if (consumes.isEmpty()) {
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
if (apiAnnotation != null) {
consumes.addAll(parseStringValues(apiAnnotation.consumes()));
}
consumes.addAll(context.getParentConsumes());
}
for (String consume : consumes) {
operation.consumes(consume);
}
}
示例6: applyProduces
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
public void applyProduces(ReaderContext context, Operation operation, Method method) {
final List<String> produces = new ArrayList<String>();
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null) {
produces.addAll(parseStringValues(apiOperation.produces()));
}
if (produces.isEmpty()) {
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
if (apiAnnotation != null) {
produces.addAll(parseStringValues(apiAnnotation.produces()));
}
produces.addAll(context.getParentProduces());
}
for (String produce : produces) {
operation.produces(produce);
}
}
示例7: applySchemes
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
public void applySchemes(ReaderContext context, Operation operation, Method method) {
final List<Scheme> schemes = new ArrayList<Scheme>();
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
if (apiOperation != null) {
schemes.addAll(parseSchemes(apiOperation.protocols()));
}
if (schemes.isEmpty() && apiAnnotation != null) {
schemes.addAll(parseSchemes(apiAnnotation.protocols()));
}
for (Scheme scheme : schemes) {
operation.scheme(scheme);
}
}
示例8: getHttpMethod
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public String getHttpMethod(ReaderContext context, Method method) {
ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null && apiOperation.httpMethod() != null && !apiOperation.httpMethod().isEmpty()) {
return apiOperation.httpMethod();
}
else {
// JAX-RS annotations
GET get = ReflectionUtils.getAnnotation(method, GET.class);
if (get != null)
return "get";
PUT put = ReflectionUtils.getAnnotation(method, PUT.class);
if (put != null) {
if (method.getName().equalsIgnoreCase("patch"))
return "patch";
return "put";
}
POST post = ReflectionUtils.getAnnotation(method, POST.class);
if (post != null)
return "post";
DELETE delete = ReflectionUtils.getAnnotation(method, DELETE.class);
if (delete != null)
return "delete";
// return our method name
if (RestService.class.isAssignableFrom(method.getDeclaringClass()))
return method.getName();
return null;
}
}
示例9: getPath
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public String getPath(ReaderContext context, Method method) {
String p = null;
Api apiAnnotation = context.getCls().getAnnotation(Api.class);
ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
String operationPath = apiOperation == null ? null : apiOperation.nickname();
if (operationPath != null && !operationPath.isEmpty()) {
// same logic as ServletReaderExtension
p = PathUtils.collectPath(context.getParentPath(),
apiAnnotation == null ? null : apiAnnotation.value(), operationPath);
}
else {
// try JAX-RS annotations
Path parentPath = ReflectionUtils.getAnnotation(method.getDeclaringClass(), Path.class);
if (parentPath != null && parentPath.value() != null && !parentPath.value().isEmpty()) {
p = parentPath.value();
}
Path path = ReflectionUtils.getAnnotation(method, Path.class);
if (path != null && path.value() != null && !path.value().isEmpty()) {
if (p == null)
p = path.value();
else {
if (path.value().startsWith("/"))
p += path.value();
else
p = p + "/" + path.value();
}
}
}
return p;
}
示例10: applyOperationId
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public void applyOperationId(Operation operation, Method method) {
ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null && StringUtils.isNotBlank(apiOperation.nickname())) {
operation.operationId(apiOperation.nickname());
}
}
示例11: applySummary
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public void applySummary(Operation operation, Method method) {
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null && StringUtils.isNotBlank(apiOperation.value())) {
operation.summary(apiOperation.value());
}
}
示例12: applyDescription
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
@Override
public void applyDescription(Operation operation, Method method) {
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null && StringUtils.isNotBlank(apiOperation.notes())) {
operation.description(apiOperation.notes());
}
operation.description(operation.getDescription() == null ? outputMethod(method)
: (outputMethod(method) + operation.getDescription()));
}
示例13: getResponseType
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
private static Type getResponseType(Method method) {
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null && !ReflectionUtils.isVoid(apiOperation.response())) {
return apiOperation.response();
} else {
return method.getGenericReturnType();
}
}
示例14: getResponseType
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
private static Type getResponseType(Method method) {
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
if (apiOperation != null && !ReflectionUtils.isVoid(apiOperation.response())) {
return apiOperation.response();
} else {
return method.getGenericReturnType();
}
}
示例15: getPath
import io.swagger.util.ReflectionUtils; //导入方法依赖的package包/类
public String getPath(ReaderContext context, Method method) {
final Api apiAnnotation = context.getCls().getAnnotation(Api.class);
final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
final String operationPath = apiOperation == null ? null : apiOperation.nickname();
return PathUtils.collectPath(context.getParentPath(),
apiAnnotation == null ? null : apiAnnotation.value(),
StringUtils.isBlank(operationPath) ? method.getName() : operationPath);
}