本文整理汇总了Java中io.swagger.util.ReflectionUtils类的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtils类的具体用法?Java ReflectionUtils怎么用?Java ReflectionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReflectionUtils类属于io.swagger.util包,在下文中一共展示了ReflectionUtils类的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: 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);
}
}
示例4: parseResponseHeaders
import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
private static Map<String, Property> parseResponseHeaders(ReaderContext context,
ResponseHeader[] headers) {
Map<String, Property> responseHeaders = null;
for (ResponseHeader header : headers) {
final String name = header.name();
if (StringUtils.isNotEmpty(name)) {
if (responseHeaders == null) {
responseHeaders = new HashMap<String, Property>();
}
final Class<?> cls = header.response();
if (!ReflectionUtils.isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls);
if (property != null) {
final Property responseProperty = ContainerWrapper.wrapContainer(
header.responseContainer(), property, ContainerWrapper.ARRAY,
ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(header.description());
responseHeaders.put(name, responseProperty);
appendModels(context.getSwagger(), cls);
}
}
}
}
return responseHeaders;
}
示例5: parseResponseHeaders
import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
private static Map<String, Property> parseResponseHeaders(Swagger swagger, ReaderContext context, ResponseHeader[] headers) {
Map<String, Property> responseHeaders = null;
for (ResponseHeader header : headers) {
final String name = header.name();
if (StringUtils.isNotEmpty(name)) {
if (responseHeaders == null) {
responseHeaders = new HashMap<String, Property>();
}
final Class<?> cls = header.response();
if (!ReflectionUtils.isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls);
if (property != null) {
final Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(),
property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(header.description());
responseHeaders.put(name, responseProperty);
appendModels(swagger, cls);
}
}
}
}
return responseHeaders;
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: getOperationPaths
import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public static Set<String> getOperationPaths(final Class<?> cls) {
final Set<String> operationPaths = new HashSet<String>();
final javax.ws.rs.Path apiPath = cls.getAnnotation(javax.ws.rs.Path.class);
final Method methods[] = cls.getMethods();
for (Method method : methods) {
if (ReflectionUtils.isOverriddenMethod(method, cls)) {
continue;
}
final javax.ws.rs.Path methodPath = getAnnotation(method, javax.ws.rs.Path.class);
String operationPath = getPath(apiPath, methodPath);
final Map<String, String> regexMap = new HashMap<String, String>();
operationPath = PathUtils.parsePath(operationPath, regexMap);
if (operationPath != null) {
operationPaths.add(operationPath);
}
}
return Collections.unmodifiableSet(operationPaths);
}
示例11: createParameter
import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
public static Parameter createParameter(Swagger swagger, ApiImplicitParam paramAnnotation) {
Parameter parameter = createParameterInstance(paramAnnotation);
Type dataType = ReflectionUtils.typeFromString(paramAnnotation.dataType());
parameter = ParameterProcessor.applyAnnotations(swagger,
parameter,
dataType,
Arrays.asList(paramAnnotation));
return parameter;
}
示例12: createResponseProperty
import io.swagger.util.ReflectionUtils; //导入依赖的package包/类
protected Property createResponseProperty() {
Type responseType = providerMethod.getReturnType();
if (ReflectionUtils.isVoid(responseType)) {
return null;
}
ResponseTypeProcessor processor = context.findResponseTypeProcessor(responseType);
return processor.process(this);
}
示例13: 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;
}
}
示例14: 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;
}
示例15: 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());
}
}