Java Code Examples for io.swagger.annotations.ApiOperation#nickname()
The following examples show how to use
io.swagger.annotations.ApiOperation#nickname() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RpcReaderExtension.java From sofa-rpc with Apache License 2.0 | 5 votes |
@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); }
Example 2
Source File: DubboReaderExtension.java From swagger-dubbo with Apache License 2.0 | 5 votes |
@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); }
Example 3
Source File: MethodUtils.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
/** * Get the operationId in schema of this method, * no matter whether it should be hidden(see {@link ApiOperation#hidden()}). * @return If the operation name is specified via {@link ApiOperation}, use that one. * Otherwise the method name is returned. */ public static String findSwaggerMethodName(Method method) { ApiOperation apiOperationAnnotation = method.getAnnotation(ApiOperation.class); if (apiOperationAnnotation == null || StringUtils.isEmpty(apiOperationAnnotation.nickname())) { return method.getName(); } return apiOperationAnnotation.nickname(); }
Example 4
Source File: ResourceReaderExtension.java From mdw with Apache License 2.0 | 4 votes |
@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(); } } // check dynamic java, which has package-based pathing java.lang.Package pkg = method.getDeclaringClass().getPackage(); if (p != null && "MDW".equals(pkg.getImplementationTitle())) { if (p.startsWith("/")) p = "/" + pkg.getName().replace('.', '/') + p; else p = "/" + pkg.getName().replace('.', '/') + "/" + p; } if (apiOperation != null) { ApiImplicitParams implicitParams = ReflectionUtils.getAnnotation(method, ApiImplicitParams.class); if (implicitParams != null && implicitParams.value() != null && implicitParams.value().length == 1) { ApiImplicitParam implicitParam = implicitParams.value()[0]; if (implicitParam.name() != null && !"body".equals(implicitParam.paramType()) && !"query".equals(implicitParam.paramType()) && !"header".equals(implicitParam.paramType()) && !"form".equals(implicitParam.paramType())) p += "/{" + implicitParam.name() + "}"; } } } return p; }