本文整理汇总了Java中io.swagger.util.ParameterProcessor类的典型用法代码示例。如果您正苦于以下问题:Java ParameterProcessor类的具体用法?Java ParameterProcessor怎么用?Java ParameterProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParameterProcessor类属于io.swagger.util包,在下文中一共展示了ParameterProcessor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createParameter
import io.swagger.util.ParameterProcessor; //导入依赖的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;
}
示例2: readParam
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
private Parameter readParam(Swagger swagger, Type type,Class<?> cls, ApiParam param) {
PrimitiveType fromType = PrimitiveType.fromType(type);
final Parameter para = null == fromType ? new FormParameter() : new QueryParameter();
Parameter parameter = ParameterProcessor.applyAnnotations(swagger, para,
type == null ? String.class : type, null == param ? new ArrayList<Annotation>()
: Collections.<Annotation> singletonList(param));
if (parameter instanceof AbstractSerializableParameter) {
final AbstractSerializableParameter<?> p = (AbstractSerializableParameter<?>) parameter;
if (p.getType() == null) p.setType(null == fromType ? "string" : fromType.getCommonName());
p.setRequired(p.getRequired() == true ? true : cls.isPrimitive());
}
return parameter;
}
示例3: readImplicitParam
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
private Parameter readImplicitParam(Swagger swagger, ApiImplicitParam param) {
PrimitiveType fromType = PrimitiveType.fromName(param.paramType());
final Parameter p = null == fromType ? new FormParameter() : new QueryParameter();
final Type type = ReflectionUtils.typeFromString(param.dataType());
return ParameterProcessor.applyAnnotations(swagger, p, type == null ? String.class : type,
Collections.<Annotation> singletonList(param));
}
示例4: readImplicitParam
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
private Parameter readImplicitParam(Swagger swagger, ApiImplicitParam param) {
final Parameter p = ParameterFactory.createParam(param.paramType());
if (p == null) {
return null;
}
final Type type = ReflectionUtils.typeFromString(param.dataType());
return ParameterProcessor.applyAnnotations(swagger, p, type == null ? String.class : type,
Collections.<Annotation>singletonList(param));
}
示例5: readImplicitParam
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
private Parameter readImplicitParam(Swagger swagger, ApiImplicitParam param) {
final Parameter p = createParam(param.paramType());
if (p == null) {
return null;
}
final Type type = typeFromString(param.dataType());
return ParameterProcessor.applyAnnotations(swagger, p, type == null ? String.class : type,
Collections.<Annotation>singletonList(param));
}
示例6: getParameters
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
private List<Parameter> getParameters(Type type, List<Annotation> annotations) {
final Iterator<SwaggerExtension> chain = SwaggerExtensions.chain();
if (!chain.hasNext()) {
return Collections.emptyList();
}
LOGGER.debug("getParameters for " + type);
Set<Type> typesToSkip = new HashSet<>();
final SwaggerExtension extension = chain.next();
LOGGER.debug("trying extension " + extension);
final List<Parameter> parameters = extension.extractParameters(annotations, type, typesToSkip, chain);
if (parameters.size() > 0) {
final List<Parameter> processed = new ArrayList<>(parameters.size());
processed.addAll(parameters.stream().filter(parameter -> ParameterProcessor
.applyAnnotations(swagger, parameter, type,
annotations) != null)
.collect(Collectors.toList()));
return processed;
} else {
LOGGER.debug("no parameter found, looking at body params");
final List<Parameter> body = new ArrayList<>();
if (!typesToSkip.contains(type)) {
Parameter param = ParameterProcessor.applyAnnotations(swagger, null, type, annotations);
if (param != null) {
body.add(param);
}
}
return body;
}
}
示例7: getParameters
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
private List<Parameter> getParameters(Type type, List<Annotation> annotations) {
final Iterator<SwaggerExtension> chain = SwaggerExtensions.chain();
if (!chain.hasNext()) {
return Collections.emptyList();
}
Logger.debug("getParameters for " + type);
Set<Type> typesToSkip = new HashSet<Type>();
final SwaggerExtension extension = chain.next();
Logger.debug("trying extension " + extension);
final List<Parameter> parameters = extension.extractParameters(annotations, type, typesToSkip, chain);
if (parameters.size() > 0) {
final List<Parameter> processed = new ArrayList<Parameter>(parameters.size());
for (Parameter parameter : parameters) {
if (ParameterProcessor.applyAnnotations(swagger, parameter, type, annotations) != null) {
processed.add(parameter);
}
}
return processed;
} else {
Logger.debug("no parameter found, looking at body params");
final List<Parameter> body = new ArrayList<Parameter>();
if (!typesToSkip.contains(type)) {
Parameter param = ParameterProcessor.applyAnnotations(swagger, null, type, annotations);
if (param != null) {
body.add(param);
}
}
return body;
}
}
示例8: getParameters
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
protected List<Parameter> getParameters(Type type, List<Annotation> annotations) {
if (!hasValidAnnotations(annotations) || isApiParamHidden(annotations)) {
return Collections.emptyList();
}
Iterator<SwaggerExtension> chain = SwaggerExtensions.chain();
List<Parameter> parameters = new ArrayList<Parameter>();
Class<?> cls = TypeUtils.getRawType(type, type);
LOG.debug("Looking for path/query/header/form/cookie params in " + cls);
if (chain.hasNext()) {
SwaggerExtension extension = chain.next();
LOG.debug("trying extension " + extension);
parameters = extension.extractParameters(annotations, type, typesToSkip, chain);
}
if (!parameters.isEmpty()) {
for (Parameter parameter : parameters) {
ParameterProcessor.applyAnnotations(swagger, parameter, type, annotations);
}
} else {
LOG.debug("Looking for body params in " + cls);
if (!typesToSkip.contains(type)) {
Parameter param = ParameterProcessor.applyAnnotations(swagger, null, type, annotations);
if (param != null) {
parameters.add(param);
}
}
}
return parameters;
}
示例9: extractParameters
import io.swagger.util.ParameterProcessor; //导入依赖的package包/类
@Override
public List<Parameter> extractParameters(List<Annotation> annotations, Type type, Set<Type> typesToSkip,
Iterator<SwaggerExtension> chain) {
// check PropertyBox type and body parameter case
if (isBodyParameter(annotations)) {
final PropertyBoxTypeInfo pbType = PropertyBoxTypeInfo.check(type).orElse(null);
if (pbType != null) {
// check property set
final PropertySetRef aps = hasApiPropertySet(annotations);
if (aps != null) {
PropertySet<?> propertySet = PropertySetRefIntrospector.get().getPropertySet(aps);
if (propertySet != null) {
// Skip PropertyBox type
Set<Type> skip = new HashSet<>();
if (typesToSkip != null) {
skip.addAll(typesToSkip);
}
skip.add(PropertyBox.class);
skip.add(PropertyBox[].class);
// load other parameters, if any
List<Parameter> parameters = new LinkedList<>();
if (chain.hasNext()) {
List<Parameter> ps = chain.next().extractParameters(annotations, type, skip, chain);
if (ps != null) {
parameters.addAll(ps);
}
}
ApiPropertySetModel psm = hasApiPropertySetModel(annotations);
final Model model = buildPropertyBoxModel(propertySet, false,
(pbType.isContainerType() && !pbType.isMap()),
(psm != null) ? AnnotationUtils.getStringValue(psm.value()) : null,
(psm != null) ? AnnotationUtils.getStringValue(psm.description()) : null,
(psm != null) ? AnnotationUtils.getStringValue(psm.reference()) : null,
SwaggerContext.getSwagger());
BodyParameter bp = new BodyParameter();
bp.setRequired(isParameterRequired(annotations));
bp.schema(model);
Parameter parameter = ParameterProcessor.applyAnnotations(new Swagger(), bp, type, annotations);
if (parameter != null) {
if (parameter instanceof BodyParameter) {
((BodyParameter) parameter).schema(model);
}
parameters.add(parameter);
}
return parameters;
}
}
}
}
return super.extractParameters(annotations, type, typesToSkip, chain);
}