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


Java ArrayProperty类代码示例

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


ArrayProperty类属于io.swagger.models.properties包,在下文中一共展示了ArrayProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: initConverters

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
private static void initConverters() {
  // inner converters
  for (Class<? extends Property> propertyCls : PROPERTY_MAP.keySet()) {
    addInnerConverter(propertyCls);
  }

  converterMap.put(RefProperty.class, new RefPropertyConverter());
  converterMap.put(ArrayProperty.class, new ArrayPropertyConverter());
  converterMap.put(MapProperty.class, new MapPropertyConverter());
  converterMap.put(StringProperty.class, new StringPropertyConverter());
  converterMap.put(ObjectProperty.class, new ObjectPropertyConverter());

  converterMap.put(ModelImpl.class, new ModelImplConverter());
  converterMap.put(RefModel.class, new RefModelConverter());
  converterMap.put(ArrayModel.class, new ArrayModelConverter());

  converterMap.put(BodyParameter.class, new BodyParameterConverter());

  AbstractSerializableParameterConverter converter = new AbstractSerializableParameterConverter();
  converterMap.put(QueryParameter.class, converter);
  converterMap.put(PathParameter.class, converter);
  converterMap.put(HeaderParameter.class, converter);
  converterMap.put(FormParameter.class, converter);
  converterMap.put(CookieParameter.class, converter);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:ConverterMgr.java

示例3: convert

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Override
public JavaType convert(ClassLoader classLoader, String packageName, Swagger swagger, Object def) {
  AbstractSerializableParameter<?> param = (AbstractSerializableParameter<?>) def;

  switch (param.getType()) {
    case ArrayProperty.TYPE:
      return ArrayPropertyConverter.findJavaType(classLoader,
          packageName,
          swagger,
          param.getItems(),
          param.isUniqueItems());
    case StringProperty.TYPE:
      return StringPropertyConverter.findJavaType(classLoader,
          packageName,
          swagger,
          param.getType(),
          param.getFormat(),
          param.getEnum());
    default:
      return ConverterMgr.findJavaType(param.getType(), param.getFormat());
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:AbstractSerializableParameterConverter.java

示例4: map

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Override
public Object map(@NonNull TupleEntity entity, @NonNull MediaType mediaType) {
  Property schema = entity.getSchemaMap().get(mediaType);

  ValueContext valueContext = ValueContext.builder().build();

  if (schema == null) {
    throw new EntityMapperRuntimeException(
        String.format("No schema found for media type '%s'.", mediaType.toString()));
  }

  if (schema instanceof ResponseProperty) {
    schema = ((ResponseProperty) schema).getSchema();
  }
  if (schema instanceof ObjectProperty) {
    return mapObject(entity, (ObjectProperty) schema, valueContext);
  }
  if (schema instanceof ArrayProperty) {
    return mapCollection(entity, (ArrayProperty) schema, valueContext);
  }

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

示例5: mapGraphValue

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Override
public Object mapGraphValue(@NonNull ArrayProperty property,
    @NonNull GraphEntityContext graphEntityContext, @NonNull ValueContext valueContext,
    @NonNull SchemaMapperAdapter schemaMapperAdapter) {
  ImmutableList.Builder<Object> builder = ImmutableList.builder();

  if (hasSubjectFilterVendorExtension(property)) {
    Set<Resource> subjects = getSubjects(property, graphEntityContext);

    subjects.forEach(subject -> {
      ValueContext subjectContext = valueContext.toBuilder().value(subject).build();

      builder.add(schemaMapperAdapter.mapGraphValue(property.getItems(), graphEntityContext,
          subjectContext, schemaMapperAdapter));
    });
  } else if (valueContext.getValue() != null) {
    if (property.getVendorExtensions().containsKey(OpenApiSpecificationExtensions.LDPATH)) {
      queryAndValidate(property, graphEntityContext, valueContext, schemaMapperAdapter, builder);
    } else {
      throw new SchemaMapperRuntimeException(String.format(
          "ArrayProperty must have a '%s' attribute", OpenApiSpecificationExtensions.LDPATH));
    }
  }

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

示例6: queryAndValidate

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
private void queryAndValidate(ArrayProperty property, GraphEntityContext graphEntityContext,
    ValueContext valueContext, SchemaMapperAdapter schemaMapperAdapter,
    ImmutableList.Builder<Object> builder) {
  LdPathExecutor ldPathExecutor = graphEntityContext.getLdPathExecutor();
  Collection<Value> queryResult = ldPathExecutor.ldPathQuery(valueContext.getValue(),
      (String) property.getVendorExtensions().get(OpenApiSpecificationExtensions.LDPATH));

  validateMinItems(property, queryResult);
  validateMaxItems(property, queryResult);

  queryResult.forEach(valueNext -> {
    ValueContext newValueContext = valueContext.toBuilder().value(valueNext).build();
    Optional innerPropertySolved =
        Optional.fromNullable(schemaMapperAdapter.mapGraphValue(property.getItems(),
            graphEntityContext, newValueContext, schemaMapperAdapter));
    builder.add(innerPropertySolved);

  });

}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:ArraySchemaMapper.java

示例7: map_MapsToMapperResult_ForRequiredPropertyWithPresentBinding

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Test
public void map_MapsToMapperResult_ForRequiredPropertyWithPresentBinding() {
  // Assert
  StringProperty nameProperty = new StringProperty().required(true);
  TupleEntity entity = new TupleEntity(
      ImmutableMap.of(MediaType.APPLICATION_JSON_TYPE, new ArrayProperty().items(
          new ObjectProperty().required(true).properties(ImmutableMap.of("name", nameProperty)))),
      result);
  when(result.hasNext()).thenReturn(true, false);
  when(result.next()).thenReturn(
      new ListBindingSet(ImmutableList.of("name"), ImmutableList.of(DBEERPEDIA.BROUWTOREN_NAME)));
  when(schemaMapper.mapTupleValue(any(StringProperty.class),
      any(ValueContext.class))).thenReturn(DBEERPEDIA.BROUWTOREN_NAME.stringValue());

  // Act
  Object mappedEntity = tupleEntityMapper.map(entity, MediaType.APPLICATION_JSON_TYPE);

  // Assert
  assertThat(mappedEntity, instanceOf(ImmutableList.class));
  assertThat((ImmutableList<Object>) mappedEntity, hasSize(1));
  assertThat((ImmutableList<Object>) mappedEntity,
      contains(ImmutableMap.of("name", DBEERPEDIA.BROUWTOREN_NAME.stringValue())));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:24,代码来源:TupleEntityMapperTest.java

示例8: map_MapsToAbsentOptionalValue_ForOptionalPropertyWithAbsentBinding

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Test
public void map_MapsToAbsentOptionalValue_ForOptionalPropertyWithAbsentBinding() {
  // Arrange
  TupleEntity entity = new TupleEntity(ImmutableMap.of(MediaType.APPLICATION_JSON_TYPE,
      new ArrayProperty().items(new ObjectProperty().properties(
          ImmutableMap.of("name", new StringProperty().required(false))))),
      result);
  when(result.hasNext()).thenReturn(true, false);
  when(result.next()).thenReturn(new ListBindingSet(ImmutableList.of(), ImmutableList.of()));

  // Act
  Object mappedEntity = tupleEntityMapper.map(entity, MediaType.APPLICATION_JSON_TYPE);

  // Assert
  assertThat(mappedEntity, instanceOf(ImmutableList.class));
  assertThat((ImmutableList<Object>) mappedEntity, hasSize(1));
  assertThat((ImmutableList<Object>) mappedEntity,
      contains(ImmutableMap.of("name", Optional.absent())));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:20,代码来源:TupleEntityMapperTest.java

示例9: map_ThrowException_ForRequiredPropertyWithAbsentBinding

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Test
public void map_ThrowException_ForRequiredPropertyWithAbsentBinding() {
  // Assert
  final TupleEntity entity = new TupleEntity(ImmutableMap.of(MediaType.APPLICATION_JSON_TYPE,
      new ArrayProperty().items(new ObjectProperty().properties(
          ImmutableMap.of("name", new StringProperty().required(true))))),
      result);
  when(result.hasNext()).thenReturn(true, false);
  when(result.next()).thenReturn(new ListBindingSet(ImmutableList.of(), ImmutableList.of()));

  // Assert
  thrown.expect(EntityMapperRuntimeException.class);
  thrown.expectMessage("Property 'name' is required.");

  // Act
  tupleEntityMapper.map(entity, MediaType.APPLICATION_JSON_TYPE);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:18,代码来源:TupleEntityMapperTest.java

示例10: mapGraphValue_ExcludesArrayProperty_WhenVendorExtIsSetAndArrayIsEmpty

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Test
public void mapGraphValue_ExcludesArrayProperty_WhenVendorExtIsSetAndArrayIsEmpty() {
  // Arrange
  ArrayProperty childProperty = new ArrayProperty(new StringProperty());

  childProperty.setVendorExtension(OpenApiSpecificationExtensions.LDPATH,
      DBEERPEDIA.NAME.stringValue());

  property.setProperties(ImmutableMap.of(DBEERPEDIA.NAME.stringValue(), childProperty));
  property.setVendorExtension(
      OpenApiSpecificationExtensions.EXCLUDE_PROPERTIES_WHEN_EMPTY_OR_NULL, true);

  when(ldPathExecutorMock.ldPathQuery(DBEERPEDIA.BROUWTOREN,
      DBEERPEDIA.NAME.stringValue())).thenReturn(ImmutableSet.of());

  // Act
  Map result = (ImmutableMap) schemaMapperAdapter.mapGraphValue(property, contextMock,
      ValueContext.builder().value(DBEERPEDIA.BROUWTOREN).build(), schemaMapperAdapter);

  // Assert
  assertThat(result.isEmpty(), is(true));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:ObjectSchemaMapperTest.java

示例11: mapGraphValue_IncludesArrayProperty_WhenVendorExtIsSetAndArrayIsNotEmpty

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Test
public void mapGraphValue_IncludesArrayProperty_WhenVendorExtIsSetAndArrayIsNotEmpty() {
  // Arrange
  ArrayProperty childProperty = new ArrayProperty(new StringProperty());

  childProperty.setVendorExtension(OpenApiSpecificationExtensions.LDPATH,
      DBEERPEDIA.NAME.stringValue());

  property.setProperties(ImmutableMap.of(DBEERPEDIA.NAME.stringValue(), childProperty));
  property.setVendorExtension(
      OpenApiSpecificationExtensions.EXCLUDE_PROPERTIES_WHEN_EMPTY_OR_NULL, true);

  when(ldPathExecutorMock.ldPathQuery(DBEERPEDIA.BROUWTOREN,
      DBEERPEDIA.NAME.stringValue())).thenReturn(ImmutableSet.of(DBEERPEDIA.BROUWTOREN_NAME));

  // Act
  Map result = (ImmutableMap) schemaMapperAdapter.mapGraphValue(property, contextMock,
      ValueContext.builder().value(DBEERPEDIA.BROUWTOREN).build(), schemaMapperAdapter);

  // Assert
  assertThat(result, is(ImmutableMap.of(DBEERPEDIA.NAME.stringValue(),
      Optional.of(ImmutableList.of(Optional.of(DBEERPEDIA.BROUWTOREN_NAME.stringValue()))))));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:24,代码来源:ObjectSchemaMapperTest.java

示例12: evaluateSchema

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
private Property evaluateSchema(Swagger swagger, Property schema) {
  Property newSchemaModel = null;
  if (schema instanceof RefProperty) {
    // Only response type defined in @ApiOperation:
    // e.g. response = JavaBean.class
    newSchemaModel = wrapWithResultContainerModel(swagger, (RefProperty) schema, SwaggerRefPropertyFactory.PropertyContainerType.NONE);
  } else if (schema instanceof ArrayProperty) {
    // Both response type and container "list" defined in @ApiOperation:
    // e.g. response = JavaBean.class, responseContainer = list
    Property itemsProperty = ArrayProperty.class.cast(schema).getItems();
    if (itemsProperty instanceof RefProperty) {
      newSchemaModel = wrapWithResultContainerModel(swagger, (RefProperty) itemsProperty, SwaggerRefPropertyFactory.PropertyContainerType.LIST);
    }
  }

  return newSchemaModel != null ? newSchemaModel : schema;
}
 
开发者ID:mnemonic-no,项目名称:common-services,代码行数:18,代码来源:ResultContainerTransformation.java

示例13: testTransformOperationForObjectList

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
@Test
public void testTransformOperationForObjectList() {
  Operation operation = createOperation(createArrayProperty());
  Swagger swagger = createSwagger(operation);

  transformation.beforeHook(swagger);
  transformation.transformOperation(swagger, operation);

  // Test that the schema points to the injected ResultContainer model definition.
  RefProperty resultContainerRefProperty = (RefProperty) swagger.getPath("/test").getGet().getResponses().get("200").getSchema();
  assertEquals("ResultContainer-TestObject-list", resultContainerRefProperty.getSimpleRef());

  // Test that the injected ResultContainer model definition exists.
  Model refModelDefinition = swagger.getDefinitions().get("ResultContainer-TestObject-list");
  assertNotNull(refModelDefinition);

  // Test that the 'data' property points to the correct model definition.
  ArrayProperty dataArrayProperty = (ArrayProperty) refModelDefinition.getProperties().get("data");
  assertEquals("TestObject", ((RefProperty) dataArrayProperty.getItems()).getSimpleRef());
}
 
开发者ID:mnemonic-no,项目名称:common-services,代码行数:21,代码来源:ResultContainerTransformationTest.java

示例14: getSchemaFromModel

import io.swagger.models.properties.ArrayProperty; //导入依赖的package包/类
private void getSchemaFromModel(Model model) {
    HashMap<String, Property> references = getAllSchemaReferencesFromModel(model);

    references.forEach((modelKey, property) -> {
        String simpleRef = null;
        Boolean isArray = false;
        if (property instanceof RefProperty) {
            simpleRef = ((RefProperty) property).getSimpleRef();
        } else {
            Property items = ((ArrayProperty) property).getItems();
            if (items instanceof RefProperty) {
                simpleRef = ((RefProperty) items).getSimpleRef();
            } else {
                return;
            }
        }
        if (simpleRef != null) {
            getDefinationsFromSchemaReference(simpleRef, modelKey);
        }

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

示例15: 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


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