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


Java ArrayProperty.getItems方法代码示例

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


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

示例1: mapCollection

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
private Object mapCollection(TupleEntity entity, ArrayProperty schema,
    ValueContext valueContext) {
  Property itemSchema = schema.getItems();

  if (itemSchema == null) {
    throw new EntityMapperRuntimeException("Array schemas must have an 'items' property.");
  }

  if (!(itemSchema instanceof ObjectProperty)) {
    throw new EntityMapperRuntimeException(
        "Only array items of type 'object' are supported for now.");
  }

  TupleQueryResult result = entity.getResult();

  ImmutableList.Builder<Map<String, Object>> collectionBuilder = new ImmutableList.Builder<>();
  Map<String, Property> itemProperties = ((ObjectProperty) itemSchema).getProperties();

  while (result.hasNext()) {
    collectionBuilder.add(mapBindingSet(result.next(), itemProperties, valueContext));
  }

  return collectionBuilder.build();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:25,代码来源:TupleEntityMapper.java

示例2: extractProperties

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
@Test
public void extractProperties() {
    final Map<String, Model> models = ModelConverters.getInstance().readAll(Family.class);
    assertEquals(models.size(), 3);

    final Model person = models.get("Person");
    final Property employer = person.getProperties().get("employer");

    assertTrue(employer instanceof ArrayProperty);
    final ArrayProperty employerProperty = (ArrayProperty) employer;

    final Property items = employerProperty.getItems();
    assertTrue(items instanceof RefProperty);
    assertEquals(((RefProperty) items).getSimpleRef(), "Employer");

    final Property awards = person.getProperties().get("awards");
    assertTrue(awards instanceof ArrayProperty);
    assertTrue(((ArrayProperty) awards).getItems() instanceof StringProperty);
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:20,代码来源:ModelPropertyTest.java

示例3: getArray

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
private static JSONArray getArray(Swagger swagger, RandomGenerator gen, ArrayProperty property) {
	JSONArray res = new JSONArray();

	int max = 1 + RandomUtils.nextInt(10);

	if (property.getItems() instanceof RefProperty) {
		for (int i = 0; i <= max; i++) {
			res.put(getRef(swagger, gen, (RefProperty) property.getItems()));
		}

	} else {
		for (int i = 0; i <= max; i++) {
			res.put(fillProperty(swagger, gen, property.getItems()));
		}
	}

	return res;
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:19,代码来源:BodyGenerator.java

示例4: getResponseList

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
/**
 * @param responseMap
 */
private MyResponse getResponseList(Map.Entry<String, Response> responseMap) {
	MyResponse response;
	String resName = responseMap.getKey();
	Response resValue = responseMap.getValue();
	Property property = resValue.getSchema();

	if(property == null){
		//Response has no schema
		response = createEmptyResponse();
		response.setDescription(resValue.getDescription());
		response.setResponseNumber(resName);
	}
	else {
		if (property instanceof ArrayProperty) {
			ArrayProperty ap = (ArrayProperty) property;
			Property p2 = ap.getItems();
			response = extractSimple(resName, resValue, p2);
		} else {
			response = extractSimple(resName, resValue, property);
		}

	} 
	return response;
}
 
开发者ID:AmadeusITGroup,项目名称:docu.me,代码行数:28,代码来源:ApiData.java

示例5: getTypeDeclaration

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
@Override
public String getTypeDeclaration(Property p) {

    if (p instanceof ArrayProperty) {
        ArrayProperty ap = (ArrayProperty) p;
        Property inner = ap.getItems();
        if (inner == null) {
            // mimic super behavior
            log.warn("{} (array property) does not have a proper inner type defined", ap.getName());
            return null;
        }

        String type = super.getTypeDeclaration(inner);
        if (!languageSpecificPrimitives.contains(type) && topLevelResources.contains(type)) {
            return type + "List";
        }
    }
    return super.getTypeDeclaration(p);
}
 
开发者ID:okta,项目名称:okta-sdk-java,代码行数:20,代码来源:AbstractOktaJavaClientCodegen.java

示例6: testCreateArrayRefProperty

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
@Test
public void testCreateArrayRefProperty() {
  ModelImpl innerModel = new ModelImpl();
  innerModel.setName("Test");

  Property property = SwaggerRefPropertyFactory.create(SwaggerRefPropertyFactory.PropertyContainerType.LIST, innerModel);
  assertTrue(property instanceof ArrayProperty);
  ArrayProperty arrayProperty = (ArrayProperty) property;
  RefProperty refProperty = (RefProperty) arrayProperty.getItems();
  assertEquals(innerModel.getName(), refProperty.getSimpleRef());
}
 
开发者ID:mnemonic-no,项目名称:common-services,代码行数:12,代码来源:SwaggerRefPropertyFactoryTest.java

示例7: verifyData

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
/**
 * Verifies that the given property is of type 'Data' containing a reference to the given model.
 * @param property The property to check
 * @param refTypeName The model name
 */
private void verifyData(Property property, String refTypeName) {
    Assert.assertTrue((property instanceof Data));

    ArrayProperty data = (ArrayProperty) ((Data) property).getProperties().get("data");

    RefProperty ref = (RefProperty) data.getItems();
    Assert.assertEquals(ref.get$ref(), "#/definitions/" + refTypeName);
}
 
开发者ID:yahoo,项目名称:elide,代码行数:14,代码来源:SwaggerBuilderTest.java

示例8: verifyDataRelationship

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
/**
 * Verifies that the given property is of type 'Data' containing a 'Relationship' with the
 * correct type field.
 * @param property The property to check
 * @param refTypeName The type field to match against
 */
private void verifyDataRelationship(Property property, String refTypeName) {
    Assert.assertTrue((property instanceof Data));

    ArrayProperty data = (ArrayProperty) ((Data) property).getProperties().get("data");

    Relationship relation = (Relationship) data.getItems();
    StringProperty type = (StringProperty) relation.getProperties().get("type");
    Assert.assertTrue(type.getEnum().contains(refTypeName));
}
 
开发者ID:yahoo,项目名称:elide,代码行数:16,代码来源:SwaggerBuilderTest.java

示例9: getType

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
public static String getType(Property property, Set<String> requiredRefinitions){
    Validate.notNull(property, "property must not be null!");
    String type;
    if(property instanceof RefProperty){
        RefProperty refProperty = (RefProperty)property;
        if(requiredRefinitions != null)
            requiredRefinitions.add(refProperty.getSimpleRef());
        return "["+refProperty.getSimpleRef()+"](#"+refProperty.getSimpleRef().toLowerCase(Locale.ENGLISH)+")";
    }else if(property instanceof ArrayProperty){
        ArrayProperty arrayProperty = (ArrayProperty)property;
        Property items = arrayProperty.getItems();
        type = getType(items, requiredRefinitions) + " " + arrayProperty.getType();
    }else if(property instanceof StringProperty){
        StringProperty stringProperty = (StringProperty)property;
        List<String> enums = stringProperty.getEnum();
        if(enums !=null && !enums.isEmpty()){
            type = "enum" + " (" + StringUtils.join(enums, ", ") + ")";
        }else{
            type = property.getType();
        }
    }
    else{
        if(StringUtils.isNotBlank(property.getFormat())){
            type = StringUtils.defaultString(property.getType()) + " (" + property.getFormat() + ")";
        }else{
            type = property.getType();
        }
    }
    return StringUtils.defaultString(type);
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:31,代码来源:PropertyUtils.java

示例10: processListsFromProperties

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
private Map<String, Model> processListsFromProperties(Collection<Property> properties, Model baseModel, Swagger swagger) {

        Map<String, Model> result = new LinkedHashMap<>();

        for (Property p : properties) {
            if (p != null && "array".equals(p.getType())) {

                ArrayProperty arrayProperty = (ArrayProperty) p;
                if ( arrayProperty.getItems() instanceof RefProperty) {
                    RefProperty ref = (RefProperty) arrayProperty.getItems();

                    String baseName = ref.getSimpleRef();

                    // Do not generate List wrappers for primitives (or strings)
                    if (!languageSpecificPrimitives.contains(baseName) && topLevelResources.contains(baseName)) {

                        String modelName = baseName + "List";

                        ModelImpl model = new ModelImpl();
                        model.setName(modelName);
                        model.setAllowEmptyValue(false);
                        model.setDescription("Collection List for " + baseName);

                        if (baseModel == null) {
                            baseModel = swagger.getDefinitions().get(baseName);
                        }

                        // only add the tags from the base model
                        if (baseModel.getVendorExtensions().containsKey("x-okta-tags")) {
                            model.setVendorExtension("x-okta-tags", baseModel.getVendorExtensions().get("x-okta-tags"));
                        }

                        model.setVendorExtension("x-isResourceList", true);
                        model.setVendorExtension("x-baseType", baseName);
                        model.setType(modelName);

                        result.put(modelName, model);
                    }
                }
            }
        }

        return result;
    }
 
开发者ID:okta,项目名称:okta-sdk-java,代码行数:45,代码来源:AbstractOktaJavaClientCodegen.java

示例11: generateExampleForArrayProperty

import io.swagger.models.properties.ArrayProperty; //导入方法依赖的package包/类
/**
 * Generates examples from an ArrayProperty
 *
 * @param value            ArrayProperty
 * @param definitions      map of definitions
 * @param markupDocBuilder the markup builder
 * @return array of Object
 */
private static Object[] generateExampleForArrayProperty(ArrayProperty value, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) {
    Property property = value.getItems();
    return getExample(property, definitions, definitionDocumentResolver, markupDocBuilder, refStack);
}
 
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:13,代码来源:ExamplesUtil.java


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