当前位置: 首页>>代码示例>>Java>>正文


Java Model.getProperties方法代码示例

本文整理汇总了Java中io.swagger.models.Model.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java Model.getProperties方法的具体用法?Java Model.getProperties怎么用?Java Model.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.swagger.models.Model的用法示例。


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

示例1: diff

import io.swagger.models.Model; //导入方法依赖的package包/类
public ModelDiff diff(Model leftModel, Model rightModel, String parentEl) {
	if (null == leftModel && null == rightModel) return this;
	Map<String, Property> leftProperties = null == leftModel ? null : leftModel.getProperties();
	Map<String, Property> rightProperties = null == rightModel ? null : rightModel.getProperties();
	MapKeyDiff<String, Property> propertyDiff = MapKeyDiff.diff(leftProperties, rightProperties);
	Map<String, Property> increasedProp = propertyDiff.getIncreased();
	Map<String, Property> missingProp = propertyDiff.getMissing();

	increased.addAll(convert2ElPropertys(increasedProp, parentEl, false));
	missing.addAll(convert2ElPropertys(missingProp, parentEl, true));

	List<String> sharedKey = propertyDiff.getSharedKey();
	for (String key : sharedKey) {
		Property left = leftProperties.get(key);
		Property right = rightProperties.get(key);
		if (left instanceof RefProperty
				&& right instanceof RefProperty) {
			String leftRef = ((RefProperty) left).getSimpleRef();
			String rightRef = ((RefProperty) right).getSimpleRef();
			diff(oldDedinitions.get(leftRef),
					newDedinitions.get(rightRef),
					null == parentEl ? key : (parentEl + "." + key));
		}
	}
	return this;
}
 
开发者ID:Sayi,项目名称:swagger-diff,代码行数:27,代码来源:ModelDiff.java

示例2: getAllProperties

import io.swagger.models.Model; //导入方法依赖的package包/类
private static Map<String, Property> getAllProperties(Map<String, Model> definitions, Model model) {
    if(model instanceof RefModel) {
        final String ref = model.getReference();
        return definitions.containsKey(ref)
                ? getAllProperties(definitions, definitions.get(model.getReference()))
                : null;
    }
    if(model instanceof ComposedModel) {
        ComposedModel composedModel = (ComposedModel)model;
        ImmutableMap.Builder<String, Property> allProperties = ImmutableMap.builder();
        if(composedModel.getAllOf() != null) {
            for(Model innerModel : composedModel.getAllOf()) {
                Map<String, Property> innerProperties = getAllProperties(definitions, innerModel);
                if(innerProperties != null) {
                    allProperties.putAll(innerProperties);
                }
            }
        }
        return allProperties.build();
    }
    else {
        return model.getProperties();
    }
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:25,代码来源:DefinitionsDocument.java

示例3: getAllSchemaReferencesFromModel

import io.swagger.models.Model; //导入方法依赖的package包/类
private HashMap<String, Property> getAllSchemaReferencesFromModel(Model model) {
    HashMap<String, Property> references = new HashMap<>();
    Map<String, Property> modelProperties = model.getProperties();
    if (modelProperties != null) {
        for (Map.Entry<String, Property> map : modelProperties.entrySet()) {
            if ("ref".equals(map.getValue().getType())
                    || "array".equals(map.getValue().getType())) {
                references.put(map.getKey(), map.getValue());
            }
        }
    }

    return references;
}
 
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:15,代码来源:SwaggerParserHelper.java

示例4: convert2ElPropertys

import io.swagger.models.Model; //导入方法依赖的package包/类
private Collection<? extends ElProperty> convert2ElPropertys(
		Map<String, Property> propMap, String parentEl, boolean isLeft) {
	List<ElProperty> result = new ArrayList<ElProperty>();
	if (null == propMap) return result;
	for (Entry<String, Property> entry : propMap.entrySet()) {
		String propName = entry.getKey();
		Property property = entry.getValue();
		if (property instanceof RefProperty) {
			String ref = ((RefProperty) property).getSimpleRef();
			Model model = isLeft ? oldDedinitions.get(ref)
					: newDedinitions.get(ref);
			if (model != null) {
				Map<String, Property> properties = model.getProperties();
				result.addAll(
						convert2ElPropertys(properties,
								null == parentEl ? propName
										: (parentEl + "." + propName),
								isLeft));
			}
		} else {
			ElProperty pWithPath = new ElProperty();
			pWithPath.setProperty(property);
			pWithPath.setEl(null == parentEl ? propName
					: (parentEl + "." + propName));
			result.add(pWithPath);
		}
	}
	return result;
}
 
开发者ID:Sayi,项目名称:swagger-diff,代码行数:30,代码来源:ModelDiff.java

示例5: validateFieldsInModel

import io.swagger.models.Model; //导入方法依赖的package包/类
private ValidationResult validateFieldsInModel(JSONObject json, Model mainModel,
        Map<String,Model> models) throws JSONException {
    ValidationResult validationResult = new ValidationResult();
    String[] passedInProperties = JSONObject.getNames(json);
    for (int i = 0; i < passedInProperties.length; i++) {
        String propertyKey = passedInProperties[i];

        if (mainModel.getProperties() == null
                || !mainModel.getProperties().containsKey(propertyKey)) {
            if (mainModel.getProperties().containsKey("get" + propertyKey)) {
                propertyKey = "get" + propertyKey;
            }
            else {
                String msg = "'" + passedInProperties[i] + "' not expected";
                if (mainModel instanceof ModelImpl)
                    msg += " on " + ((ModelImpl) mainModel).getName();
                validationResult.addValidationMessage(new ValidationMessage().message(msg));
            }
        }
        Property modelProperty = mainModel.getProperties().get(propertyKey);
        // If it's a RefProperty then look at that
        if (modelProperty instanceof RefProperty) {
            String name = ((RefProperty) modelProperty).getSimpleRef();
            validationResult.addValidationMessages(
                    (validateFieldsInModel(json.getJSONObject(passedInProperties[i]),
                            models.get(name), models)));
        }
    }
    return validationResult;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:31,代码来源:CompatibleValidator.java

示例6: validateFields

import io.swagger.models.Model; //导入方法依赖的package包/类
private ValidationResult validateFields(JSONObject json, Model model,
        Map<String,Model> swaggerModels) throws ValidationException {
    Map<String, Property> modelFields = model.getProperties();
    ValidationResult validationResult = new ValidationResult();
    for (Map.Entry<String, Property> prop : modelFields.entrySet()) {
        try {
            String property = prop.getKey();
            Property modelProperty = prop.getValue();
            if (!json.has(property)) {
                // Hack for 911Address which seems to return get911Address
                // for some reason
                if (property.startsWith("get")) {
                    property = property.substring(3);
                }
            }
            // Check for requiredness
            if (!json.has(property) || json.get(property) == null
                    || json.isNull(property)) {
                if (modelProperty.getRequired()) {
                    String msg = "'" + property + "' is a required property";
                    if (model instanceof ModelImpl)
                        msg += " on " + ((ModelImpl)model).getName();
                    validationResult.addValidationMessage(new ValidationMessage().message(msg));
                }
            }
            else {
                if (modelProperty instanceof RefProperty) {
                    // Got a class, so process this class for required
                    // fields
                    String name = ((RefProperty) modelProperty).getSimpleRef();
                    validationResult
                            .addValidationMessages((validateFields(json.getJSONObject(property),
                                    swaggerModels.get(name), swaggerModels)));
                }
                // Validate formats only if not a required error
                // and there is some kind of value
                Iterator<Validator> itr = validators.iterator();

                if (itr.hasNext()) {
                    Validator validator = itr.next();
                    validationResult.addValidationMessages(
                            validator.validate(json, property, modelProperty, itr));
                }
            }
        }
        catch (Exception e) {
            // include e in ValidationException constructor so that root cause is not lost
            throw new ValidationException(
                    new ValidationMessage().message(e.getMessage()), e);
        }
    }
    return validationResult;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:54,代码来源:CompatibleValidator.java


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