本文整理汇总了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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}