Refine search
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; }
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()); } }
public static Annotation[][] findParamAnnotations(Method method) { Annotation[][] paramAnnotation = method.getParameterAnnotations(); Method overriddenMethod = ReflectionUtils.getOverriddenMethod(method); while(overriddenMethod != null) { paramAnnotation = merge(overriddenMethod.getParameterAnnotations(), paramAnnotation); overriddenMethod = ReflectionUtils.getOverriddenMethod(overriddenMethod); } return paramAnnotation; }
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(); } }
ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); ApiResponses responseAnnotation = ReflectionUtils.getAnnotation(method, ApiResponses.class); methodInSuperType = ReflectionUtils.findMethod(method, cls.getSuperclass()) != null; methodInSuperType = ReflectionUtils.findMethod(method, implementedInterface) != null; if (methodInSuperType) { break; JsonView jsonViewAnnotation = ReflectionUtils.getAnnotation(method, JsonView.class); final Consumes consumes = ReflectionUtils.getAnnotation(method, Consumes.class); if (consumes != null) { for (String mediaType : ReaderUtils.splitContentValues(consumes.value())) { final Produces produces = ReflectionUtils.getAnnotation(method, Produces.class); if (produces != null) { for (String mediaType : ReaderUtils.splitContentValues(produces.value())) { ApiResponses exceptionResponses = ReflectionUtils.getAnnotation(exceptionType, ApiResponses.class); if (exceptionResponses != null) { apiResponses.addAll(Arrays.asList(exceptionResponses.value())); if (ReflectionUtils.getAnnotation(method, Deprecated.class) != null) { Annotation[][] paramAnnotations = ReflectionUtils.getParameterAnnotations(method); if (annotatedMethod == null) { Type[] genericParameterTypes = method.getGenericParameterTypes();
final Set<Scheme> globalSchemes = EnumSet.noneOf(Scheme.class); Api api = ReflectionUtils.getAnnotation(cls, Api.class); boolean hasPathAnnotation = (ReflectionUtils.getAnnotation(cls, javax.ws.rs.Path.class) != null); boolean hasApiAnnotation = (api != null); boolean isApiHidden = hasApiAnnotation && api.hidden(); ApiResponses classResponseAnnotation = ReflectionUtils.getAnnotation(cls, ApiResponses.class); List<ApiResponse> classApiResponses = new ArrayList<ApiResponse>(); if (classResponseAnnotation != null) { final javax.ws.rs.Path apiPath = ReflectionUtils.getAnnotation(cls, javax.ws.rs.Path.class); JavaType classType = TypeFactory.defaultInstance().constructType(cls); BeanDescription bd = new ObjectMapper().getSerializationConfig().introspect(classType); for (Method method : methods) { AnnotatedMethod annotatedMethod = bd.findMethod(method.getName(), method.getParameterTypes()); if (ReflectionUtils.isOverriddenMethod(method, cls)) { continue; javax.ws.rs.Path methodPath = ReflectionUtils.getAnnotation(method, javax.ws.rs.Path.class); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); String httpMethod = extractOperationMethod(apiOperation, method, SwaggerExtensions.chain()); operation.parameter(param);
private void read(ReaderContext context) { if (ReflectionUtils.isOverriddenMethod(method, context.getCls())) { continue; final Operation operation = new Operation(); if ("post".equalsIgnoreCase(httpMethod) && operation.getConsumes() == null) { operation.addConsumes("application/x-www-form-urlencoded");
Map<Method, Method> serviceMethods = new LinkedHashMap<Method, Method>(); for (Method method : interfaceMethodList) { if (!ReflectionUtils.isOverriddenMethod(method, context.getCls())) { serviceMethods.put(method, getRefMethod(context, method)); Method interfaceMethod = entry.getKey(); final Operation operation = new Operation(); String operationPath = null; String httpMethod = null; if (operation.getResponses() == null) { operation.defaultResponse(new Response().description("successful operation"));
public void applyResponses(Swagger swagger, ReaderContext context, Operation operation, Method method) { final Map<Integer, Response> result = new HashMap<Integer, Response>(); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); if (apiOperation != null && StringUtils.isNotBlank(apiOperation.responseReference())) { final Response response = new Response().description(SUCCESSFUL_OPERATION); response.schema(new RefProperty(apiOperation.responseReference())); result.put(apiOperation.code(), response); final ApiResponses responseAnnotation = ReflectionUtils.getAnnotation(method, ApiResponses.class); if (responseAnnotation != null) { for (ApiResponse apiResponse : responseAnnotation.value()) { } else if (!ReflectionUtils.isVoid(apiResponse.response())) { final Type type = apiResponse.response(); final Property property = ModelConverters.getInstance().readAsProperty(type); operation.defaultResponse(responseEntry.getValue()); } else { operation.response(responseEntry.getKey(), responseEntry.getValue());
@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())); }
public void applyTags(ReaderContext context, Operation operation, Method method) { final List<String> tags = new ArrayList<String>(); final Api apiAnnotation = context.getCls().getAnnotation(Api.class); if (apiAnnotation != null) { tags.addAll(Collections2.filter(Arrays.asList(apiAnnotation.tags()), new Predicate<String>() { public boolean apply(String input) { return StringUtils.isNotBlank(input); } })); } tags.addAll(context.getParentTags()); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); if (apiOperation != null) { tags.addAll(Collections2.filter(Arrays.asList(apiOperation.tags()), new Predicate<String>() { public boolean apply(String input) { return StringUtils.isNotBlank(input); } })); } for (String tag : tags) { operation.tag(tag); } }
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); } }
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); } }
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()); } }
public void applyOperationId(Operation operation, Method method) { final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); if (apiOperation != null && StringUtils.isNotBlank(apiOperation.nickname())) { operation.operationId(apiOperation.nickname()); } else { operation.operationId(method.getName()); } }
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); } }
public String extractOperationMethod(ApiOperation apiOperation, Method method, Iterator<SwaggerExtension> chain) { if (apiOperation != null && apiOperation.httpMethod() != null && !"".equals(apiOperation.httpMethod())) { return apiOperation.httpMethod().toLowerCase(Locale.US); } else if (method.getAnnotation(javax.ws.rs.GET.class) != null) { return "get"; } else if (method.getAnnotation(javax.ws.rs.PUT.class) != null) { return "put"; } else if (method.getAnnotation(javax.ws.rs.POST.class) != null) { return "post"; } else if (method.getAnnotation(javax.ws.rs.DELETE.class) != null) { return "delete"; } else if (method.getAnnotation(javax.ws.rs.OPTIONS.class) != null) { return "options"; } else if (method.getAnnotation(javax.ws.rs.HEAD.class) != null) { return "head"; } else if (method.getAnnotation(PATCH.class) != null) { return "patch"; } else if (method.getAnnotation(HttpMethod.class) != null) { HttpMethod httpMethod = method.getAnnotation(HttpMethod.class); return httpMethod.value().toLowerCase(Locale.US); } else if (!StringUtils.isEmpty(getHttpMethodFromCustomAnnotations(method))) { return getHttpMethodFromCustomAnnotations(method); } else if ((ReflectionUtils.getOverriddenMethod(method)) != null) { return extractOperationMethod(apiOperation, ReflectionUtils.getOverriddenMethod(method), chain); } else if (chain != null && chain.hasNext()) { return chain.next().extractOperationMethod(apiOperation, method, chain); } else { return null; } }
try { m = refClass.getMethod(method.getName(), method.getParameterTypes()); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(m, ApiOperation.class); String nickname = null == apiOperation ? null : apiOperation.nickname(); if (operationId != null) { if (!operationId.equals(nickname)) continue; String httpMethod = null == apiOperation ? null : apiOperation.httpMethod(); if (StringUtils.isNotBlank(httpMethod) && !requestMethod.equals(httpMethod)) continue;
@Override public String getPath(ReaderContext context, Method method) { final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); String operationId = null == apiOperation ? "" : StringUtils.isBlank(apiOperation.nickname()) ? null : apiOperation.nickname(); return PathUtils.collectPath(context.getParentPath(), context.getInterfaceCls().getName(), method.getName(), operationId); }
public String getHttpMethod(ReaderContext context, Method method) { final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); return apiOperation == null || StringUtils.isEmpty(apiOperation.httpMethod()) ? context.getParentHttpMethod() : apiOperation.httpMethod(); }