Java Code Examples for io.swagger.util.PathUtils#collectPath()
The following examples show how to use
io.swagger.util.PathUtils#collectPath() .
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: ControllerReaderExtension.java From jboot with Apache License 2.0 | 5 votes |
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); }
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; }