Java Code Examples for io.swagger.annotations.ApiImplicitParams#value()

The following examples show how to use io.swagger.annotations.ApiImplicitParams#value() . 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: ResourceReaderExtension.java    From mdw with Apache License 2.0 6 votes vote down vote up
/**
 * Implemented to allow loading of custom types using PackageClassLoader.
 */
@Override
public void applyImplicitParameters(ReaderContext context, Operation operation, Method method) {
    // copied from io.swagger.servlet.extensions.ServletReaderExtension
    final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class);
    if (implicitParams != null && implicitParams.value().length > 0) {
        for (ApiImplicitParam param : implicitParams.value()) {
            final Parameter p = readImplicitParameter(context.getSwagger(), param);
            if (p != null) {
                if (p instanceof BodyParameter && param.format() != null)
                    p.getVendorExtensions().put("format", param.format());
                operation.parameter(p);
            }
        }
    }
}
 
Example 2
Source File: Reader.java    From dorado with Apache License 2.0 5 votes vote down vote up
private void processImplicitParams(ApiImplicitParams implicitParams, Operation operation) {
	if (implicitParams != null) {
		for (ApiImplicitParam param : implicitParams.value()) {
			Parameter p = readImplicitParam(param);
			if (p != null) {
				operation.addParameter(p);
			}
		}
	}
}
 
Example 3
Source File: RpcReaderExtension.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
@Override
public void applyImplicitParameters(ReaderContext context, Operation operation, Method method) {
    final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class);
    if (implicitParams != null && implicitParams.value().length > 0) {
        for (ApiImplicitParam param : implicitParams.value()) {
            final Parameter p = readImplicitParam(context.getSwagger(), param);
            if (p != null) {
                operation.parameter(p);
            }
        }
    }
}
 
Example 4
Source File: DubboReaderExtension.java    From swagger-dubbo with Apache License 2.0 5 votes vote down vote up
@Override
public void applyImplicitParameters(ReaderContext context, Operation operation, Method method) {
	final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class);
	if (implicitParams != null && implicitParams.value().length > 0) {
		for (ApiImplicitParam param : implicitParams.value()) {
			final Parameter p = readImplicitParam(context.getSwagger(), param);
			if (p != null) {
				operation.parameter(p);
			}
		}
	}
}
 
Example 5
Source File: ExtendedSwaggerReader.java    From msf4j with Apache License 2.0 5 votes vote down vote up
private void readImplicitParameters(Method method, Operation operation) {
    ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class);
    if (implicitParams != null && implicitParams.value().length > 0) {
        for (ApiImplicitParam param : implicitParams.value()) {
            Parameter p = readImplicitParam(param);
            if (p != null) {
                operation.addParameter(p);
            }
        }
    }
}
 
Example 6
Source File: ResourceReaderExtension.java    From mdw with Apache License 2.0 4 votes vote down vote up
@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;
}