• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RefParameter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.swagger.models.parameters.RefParameter的典型用法代码示例。如果您正苦于以下问题:Java RefParameter类的具体用法?Java RefParameter怎么用?Java RefParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RefParameter类属于io.swagger.models.parameters包,在下文中一共展示了RefParameter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getResolvedParameters

import io.swagger.models.parameters.RefParameter; //导入依赖的package包/类
/**
 * Ensures the parameters are all resolved and return just the list of parameters that are fully
 * resolved by the swagger core parser.
 */
private static ImmutableList<Parameter> getResolvedParameters(
    final DiagCollector diagCollector,
    ImmutableList<Parameter> parameters,
    final Location location) {
  ImmutableList<Parameter> resolvedParameters =
      FluentIterable.from(parameters)
          .filter(
              new Predicate<Parameter>() {
                @Override
                public boolean apply(Parameter parameter) {
                  if (parameter instanceof RefParameter) {
                    /*
                     * This is an invalid state. Reference parameters should automatically get
                     * resolved into parameter objects by the swagger core parser, because only
                     * references that are allowed are to parameters that are defined at the
                     * Swagger Object's parameters which are in the same file. If we reach here
                     * it would mean the reference cannot be resolved and nothing this converter
                     * can do.
                     */
                    diagCollector.addDiag(
                        Diag.warning(
                            location,
                            "Reference %s cannot be resolved",
                            ((RefParameter) parameter).get$ref()));
                    return false;
                  } else {
                    return true;
                  }
                }
              })
          .toList();
  return resolvedParameters;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:38,代码来源:ProtoApiFromOpenApi.java


示例2: createPropertyFromParameter

import io.swagger.models.parameters.RefParameter; //导入依赖的package包/类
static Optional<ConfigurationProperty> createPropertyFromParameter(final Parameter parameter) {
    if (parameter instanceof RefParameter || parameter instanceof BodyParameter) {
        // Reference parameters are not supported, body parameters are
        // handled in createShape* methods

        return Optional.empty();
    }

    if (!(parameter instanceof SerializableParameter)) {
        throw new IllegalStateException(
            "Unexpected parameter type received, neither ref, body nor serializable: " + parameter);
    }

    final String name = parameter.getName();
    final String description = parameter.getDescription();
    final boolean required = parameter.getRequired();

    final ConfigurationProperty.Builder propertyBuilder = new ConfigurationProperty.Builder()//
        .kind("property")//
        .displayName(name)//
        .description(description)//
        .group("producer")//
        .required(required)//
        .componentProperty(false)//
        .deprecated(false)//
        .secret(false);

    final SerializableParameter serializableParameter = (SerializableParameter) parameter;

    final String type = serializableParameter.getType();
    propertyBuilder.type(type).javaType(JsonSchemaHelper.javaTypeFor(serializableParameter));

    final List<String> enums = serializableParameter.getEnum();
    if (enums != null) {
        propertyBuilder.addAllEnum(createEnums(enums));
    }

    return Optional.of(propertyBuilder.build());
}
 
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:40,代码来源:SwaggerConnectorGenerator.java


示例3: getType

import io.swagger.models.parameters.RefParameter; //导入依赖的package包/类
/**
 * Retrieves the type of a parameter, or otherwise null
 *
 * @param definitionDocumentResolver the definition document resolver
 * @return the type of the parameter, or otherwise null
 */
private Type getType(Map<String, Model> definitions, DocumentResolver definitionDocumentResolver) {
    Validate.notNull(parameter, "parameter must not be null!");
    Type type = null;

    if (parameter instanceof BodyParameter) {
        BodyParameter bodyParameter = (BodyParameter) parameter;
        Model model = bodyParameter.getSchema();

        if (model != null) {
            type = ModelUtils.getType(model, definitions, definitionDocumentResolver);
        } else {
            type = new BasicType("string", bodyParameter.getName());
        }

    } else if (parameter instanceof AbstractSerializableParameter) {
        AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter;
        @SuppressWarnings("unchecked")
        List<String> enums = serializableParameter.getEnum();

        if (CollectionUtils.isNotEmpty(enums)) {
            type = new EnumType(serializableParameter.getName(), enums);
        } else {
            type = new BasicType(serializableParameter.getType(), serializableParameter.getName(), serializableParameter.getFormat());
        }
        if (serializableParameter.getType().equals("array")) {
            String collectionFormat = serializableParameter.getCollectionFormat();

            type = new ArrayType(serializableParameter.getName(), new PropertyAdapter(serializableParameter.getItems()).getType(definitionDocumentResolver), collectionFormat);
        }
    } else if (parameter instanceof RefParameter) {
        String refName = ((RefParameter) parameter).getSimpleRef();

        type = new RefType(definitionDocumentResolver.apply(refName), new ObjectType(refName, null /* FIXME, not used for now */));
    }
    return type;
}
 
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:43,代码来源:ParameterAdapter.java


示例4: getType

import io.swagger.models.parameters.RefParameter; //导入依赖的package包/类
public static String getType(Parameter parameter, Set<String> definitions){
    Validate.notNull(parameter, "property must not be null!");
    String type = "NOT FOUND";
    if(parameter instanceof BodyParameter){
        BodyParameter bodyParameter = (BodyParameter)parameter;
        Model model = bodyParameter.getSchema();
        if(model != null){
            type = ModelUtils.getType(model);
        }else{
            type = "string";
        }

    }
    else if(parameter instanceof AbstractSerializableParameter){
        AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter)parameter;
        List enums = serializableParameter.getEnum();
        if(enums != null && !enums.isEmpty()){
            type = "enum" + " (" + StringUtils.join(enums, ", ") + ")";
        }else{
            type = getTypeWithFormat(serializableParameter.getType(), serializableParameter.getFormat());
        }
        if(type.equals("array")){
            String collectionFormat = serializableParameter.getCollectionFormat();
            type = collectionFormat + " " + PropertyUtils.getType(serializableParameter.getItems()) + " " + type;
        }
    }
    else if(parameter instanceof RefParameter){
        RefParameter refParameter = (RefParameter)parameter;
        if(definitions != null) {
            definitions.add(refParameter.getSimpleRef());
        }
        return "["+refParameter.getSimpleRef()+"](#"+refParameter.getSimpleRef().toLowerCase(Locale.ENGLISH)+")";
    }
    return StringUtils.defaultString(type);
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:36,代码来源:ParameterUtils.java


示例5: createPropertyFromParameter

import io.swagger.models.parameters.RefParameter; //导入依赖的package包/类
static Optional<ConfigurationProperty> createPropertyFromParameter(final Parameter parameter) {
    if (parameter instanceof RefParameter || parameter instanceof BodyParameter) {
        // Reference parameters are not supported, body parameters are
        // handled in createShape* methods

        return Optional.empty();
    }

    if (!(parameter instanceof AbstractSerializableParameter<?>)) {
        throw new IllegalArgumentException("Unexpected parameter type received, neither ref, body nor serializable: " + parameter);
    }

    final String name = trimToNull(parameter.getName());
    final String description = trimToNull(parameter.getDescription());
    final boolean required = parameter.getRequired();

    final ConfigurationProperty.Builder propertyBuilder = new ConfigurationProperty.Builder()//
        .kind("property")//
        .displayName(name)//
        .description(description)//
        .group("producer")//
        .required(required)//
        .componentProperty(false)//
        .deprecated(false)//
        .secret(false);

    final AbstractSerializableParameter<?> serializableParameter = (AbstractSerializableParameter<?>) parameter;

    final Object defaultValue = serializableParameter.getDefaultValue();
    if (defaultValue != null) {
        propertyBuilder.defaultValue(String.valueOf(defaultValue));
    }

    final String type = serializableParameter.getType();
    propertyBuilder.type(type).javaType(JsonSchemaHelper.javaTypeFor(serializableParameter));

    final List<String> enums = serializableParameter.getEnum();
    if (enums != null) {
        propertyBuilder.addAllEnum(createEnums(enums));
    }

    return Optional.of(propertyBuilder.build());
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:44,代码来源:BaseSwaggerConnectorGenerator.java


示例6: convertParameterToType

import io.swagger.models.parameters.RefParameter; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private AbstractType convertParameterToType(Parameter p) {
	if (p instanceof AbstractSerializableParameter<?>) {
		AbstractSerializableParameter<?> basicModel = (AbstractSerializableParameter<?>) p;
		String type = basicModel.getType();
		if (type == null && basicModel.getMinimum() != null) {
			type = "number";
		}
		if (type == null && basicModel.getMaximum() != null) {
			type = "number";
		}

		if (type == null && basicModel.getEnum() != null) {
			type = "string";
		}

		if (type != null && type.equals("array")) {
			if (basicModel.getEnum() != null) {
				type = "string";
			}
			// FIXME
		}
		if (type != null && type.equals("boolean")) {
			basicModel.setEnum(null);// FIXME
		}
		String format = basicModel.getFormat();
		FormatMapper mapFormat = FormatMapper.mapFormat(new FormatMapper(type, format));
		type = mapFormat.type;
		if (((AbstractSerializableParameter) p).getEnum() != null) {
			@SuppressWarnings("unchecked")
			LinkedHashSet<Object> linkedHashSet = new LinkedHashSet<>(
					((AbstractSerializableParameter) p).getEnum());
			linkedHashSet.remove(null);
			((AbstractSerializableParameter) p).setEnum(new ArrayList<>(linkedHashSet));
		}
		format = mapFormat.format;
		AbstractType st = base(type);
		AbstractType derive = TypeOps.derive("", st);
		transferTo(derive, Description.class, basicModel.getDescription());
		transferTo(derive, Example.class, basicModel.getExample());
		transferTo(derive, DisplayName.class, basicModel.getName());
		transferTo(derive, Default.class, basicModel.getDefaultValue());
		transferTo(derive, Enum.class, basicModel.getEnum());

		transferTo(derive, Format.class, format);
		transferTo(derive, MaxLength.class, basicModel.getMaxLength());
		transferTo(derive, MinLength.class, basicModel.getMinLength());
		transferTo(derive, Pattern.class, basicModel.getPattern());
		transferTo(derive, Enum.class, basicModel.getEnum());
		transferTo(derive, Minimum.class, basicModel.getMinimum());
		transferTo(derive, Maximum.class, basicModel.getMaximum());
		Property items = basicModel.getItems();
		if (items != null) {
			derive.addMeta(new ComponentShouldBeOfType(propertyToType(items)));
		}
		return derive;
	} else if (p instanceof RefParameter) {
		throw new IllegalStateException();
	} else if (p instanceof BodyParameter) {
		BodyParameter bp = (BodyParameter) p;
		Model schema = bp.getSchema();
		AbstractType convertType = convertType("", schema);
		transferTo(convertType, Description.class, bp.getDescription());
		transferTo(convertType, Example.class, bp.getExamples());
		return convertType;
	} else {
		throw new IllegalStateException();
	}
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:70,代码来源:SwaggerReader.java



注:本文中的io.swagger.models.parameters.RefParameter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OffsetMetadataAndError类代码示例发布时间:2022-05-23
下一篇:
Java PredicateUtils类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap