本文整理汇总了Java中io.swagger.models.ArrayModel类的典型用法代码示例。如果您正苦于以下问题:Java ArrayModel类的具体用法?Java ArrayModel怎么用?Java ArrayModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayModel类属于io.swagger.models包,在下文中一共展示了ArrayModel类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initConverters
import io.swagger.models.ArrayModel; //导入依赖的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
示例2: extract
import io.swagger.models.ArrayModel; //导入依赖的package包/类
@Override
public Object extract(String name, Parameter parameter, RoutingContext context) {
BodyParameter bodyParam = (BodyParameter) parameter;
if ("".equals(context.getBodyAsString())) {
if (bodyParam.getRequired())
throw new IllegalArgumentException("Missing required parameter: " + name);
else
return null;
}
try {
if(bodyParam.getSchema() instanceof ArrayModel) {
return context.getBodyAsJsonArray();
} else {
return context.getBodyAsJson();
}
} catch (DecodeException e) {
return context.getBodyAsString();
}
}
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:21,代码来源:BodyParameterExtractor.java
示例3: testFillBodyArray
import io.swagger.models.ArrayModel; //导入依赖的package包/类
@Test
public void testFillBodyArray() {
for (int i = 0; i < 100; i++) {
StringProperty stringProp = new StringProperty();
stringProp.setType("string");
stringProp.setFormat("");
stringProp.setMinLength(10);
ArrayModel array = new ArrayModel();
array.setType("string");
array.setItems(stringProp);
Object res = BodyGenerator.fillBody(swagger.getSwagger(), array, TestType.VALID);
assertNotNull(res);
assertTrue(res instanceof JSONArray);
JSONArray json = (JSONArray) res;
json.forEach(elem -> assertTrue(elem instanceof String));
json.forEach(elem -> assertTrue(((String) elem).length() >= 10));
}
}
开发者ID:lpelleau,项目名称:SwagTester,代码行数:24,代码来源:TestBodyGenerator.java
示例4: collectRefProperty
import io.swagger.models.ArrayModel; //导入依赖的package包/类
protected DataProvider collectRefProperty(Swagger swagger, RefProperty schema, boolean clean) {
Model model = swagger.getDefinitions() != null ? swagger.getDefinitions().get(schema.getSimpleRef()) : null;
if (model == null) throw new IllegalArgumentException("CAN'T find model for " + schema.getSimpleRef());
if (model instanceof ArrayModel) {
DataProvider itemProvider = collect(swagger, ((ArrayModel) model).getItems(), clean);
return new ListDataProvider(itemProvider, schema.getSimpleRef());
} else if (model instanceof ModelImpl) {
Map<String, DataProvider> fields =
(model.getProperties() != null ? model.getProperties() : Collections.<String, Property>emptyMap()).entrySet().stream()
.map(e -> entry(e.getKey(), collect(swagger, e.getValue(), clean)))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return new ObjectDataProvider(fields, schema.getSimpleRef());
}
throw new IllegalArgumentException("Unsupported model type: " + model.getClass());
}
开发者ID:tminglei,项目名称:binder-swagger-java,代码行数:19,代码来源:DataProviders.java
示例5: testMtoModel
import io.swagger.models.ArrayModel; //导入依赖的package包/类
@Test
public void testMtoModel() {
Model model = converter.mToModel(list(mapping(
field("id", $(intv()).desc("id").$$),
field("name", $(text(required())).desc("name").$$)
)));
assertTrue(model instanceof ArrayModel);
ArrayModel m = (ArrayModel) model;
assertTrue(m.getItems() instanceof ObjectProperty);
ObjectProperty p = (ObjectProperty) m.getItems();
assertTrue(p.getProperties() != null);
assertEquals(p.getProperties().size(), 2);
assertTrue(p.getProperties().get("id") instanceof IntegerProperty);
assertTrue(p.getProperties().get("name") instanceof StringProperty);
IntegerProperty p1 = (IntegerProperty) p.getProperties().get("id");
assertEquals(p1.getRequired(), false);
assertEquals(p1.getFormat(), "int32");
assertEquals(p1.getDescription(), "id");
StringProperty p2 = (StringProperty) p.getProperties().get("name");
assertEquals(p2.getRequired(), true);
assertEquals(p2.getDescription(), "name");
}
开发者ID:tminglei,项目名称:binder-swagger-java,代码行数:27,代码来源:MappingConverterImplTest.java
示例6: processModelRefs
import io.swagger.models.ArrayModel; //导入依赖的package包/类
private static void processModelRefs(io.swagger.models.Model model, Map<String, Integer> modelRefCount) {
if (model instanceof RefModel) {
String ref = ((RefModel) model).getSimpleRef();
Integer count = modelRefCount.get(ref);
modelRefCount.put(ref, count != null ? (count + 1) : 1);
} else if (model instanceof ModelImpl) {
processPropertyModelRefs(((ModelImpl) model).getProperties(), modelRefCount);
processPropertyModelRefs(((ModelImpl) model).getAdditionalProperties(), modelRefCount);
} else if (model instanceof ArrayModel) {
processPropertyModelRefs(((ArrayModel) model).getProperties(), modelRefCount);
processPropertyModelRefs(((ArrayModel) model).getItems(), modelRefCount);
} else if (model instanceof ComposedModel) {
processPropertyModelRefs(((ComposedModel) model).getProperties(), modelRefCount);
processModelRefs(((ComposedModel) model).getChild(), modelRefCount);
processModelRefs(((ComposedModel) model).getParent(), modelRefCount);
processModelRefs(((ComposedModel) model).getAllOf(), modelRefCount);
processModelRefs(((ComposedModel) model).getInterfaces(), modelRefCount);
}
}
开发者ID:isabinin,项目名称:aws-apigateway-swagger-exporter,代码行数:21,代码来源:APIGExporter.java
示例7: doConvert
import io.swagger.models.ArrayModel; //导入依赖的package包/类
@Override
public JavaType doConvert(ClassLoader classLoader, String packageName, Swagger swagger, Object model) {
ArrayModel arrayModel = (ArrayModel) model;
if (arrayModel.getItems() != null) {
return ArrayPropertyConverter.findJavaType(classLoader,
packageName,
swagger,
arrayModel.getItems(),
false);
}
// don't know when will this happen.
throw new Error("not support null array model items.");
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:16,代码来源:ArrayModelConverter.java
示例8: createSchemaFromModel
import io.swagger.models.ArrayModel; //导入依赖的package包/类
private static JsonNode createSchemaFromModel(final String specification, final Model schema) {
if (schema instanceof ArrayModel) {
final Property items = ((ArrayModel) schema).getItems();
return createSchemaFromProperty(specification, items);
} else if (schema instanceof ModelImpl) {
return createSchemaFromModelImpl(schema);
}
final String title = Optional.ofNullable(schema.getTitle()).orElse(schema.getReference().replaceAll("^.*/", ""));
return createSchemaFromReference(specification, title, schema.getReference());
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:SwaggerUnifiedShapeConnectorGenerator.java
示例9: createShapeFromModel
import io.swagger.models.ArrayModel; //导入依赖的package包/类
static DataShape createShapeFromModel(final String specification, final Model schema) {
if (schema instanceof ArrayModel) {
final Property items = ((ArrayModel) schema).getItems();
return createShapeFromProperty(specification, items);
} else if (schema instanceof ModelImpl) {
return createShapeFromModelImpl(schema);
}
final String title = Optional.ofNullable(schema.getTitle()).orElse(schema.getReference().replaceAll("^.*/", ""));
return createShapeFromReference(specification, title, schema.getReference());
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:DataShapeHelper.java
示例10: createShapeFromModel
import io.swagger.models.ArrayModel; //导入依赖的package包/类
static DataShape createShapeFromModel(final String specification, final Model schema) {
if (schema instanceof ArrayModel) {
final Property items = ((ArrayModel) schema).getItems();
return createShapeFromProperty(specification, items);
} else if (schema instanceof ModelImpl) {
return createShapeFromModelImpl(schema);
}
final String title = Optional.ofNullable(schema.getTitle())
.orElse(schema.getReference().replaceAll("^.*/", ""));
return createShapeFromReference(specification, title, schema.getReference());
}
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:15,代码来源:SwaggerConnectorGenerator.java
示例11: getType
import io.swagger.models.ArrayModel; //导入依赖的package包/类
public static String getType(Model model) {
Validate.notNull(model, "model must not be null!");
if (model instanceof ModelImpl) {
return ((ModelImpl) model).getType();
} else if (model instanceof RefModel) {
return ((RefModel) model).getSimpleRef();
} else if (model instanceof ArrayModel) {
ArrayModel arrayModel = ((ArrayModel) model);
return PropertyUtils.getType(arrayModel.getItems()) + " " + arrayModel.getType();
}
return "NOT FOUND";
}
开发者ID:buremba,项目名称:swagger-slate,代码行数:13,代码来源:ModelUtils.java
示例12: addTypeFromModel
import io.swagger.models.ArrayModel; //导入依赖的package包/类
/**
* Create the {@link Type} instance from model.
*
* <p>NOTE: If the property of the model references another model, then we recursively create the
* {@link Type} corresponding to the reference model.
*
* <p>NOTE: {@link Type} is created only if the model is a ModelImpl (corresponds to JSON Object)
* and does not contain additional properties. For other cases we cannot create a Protobuf.Type
* instance (Example: ModelImpl with additional properties, array model etc). For such cases just
* return the suitable predefined google.protobuf* types.
*/
TypeInfo addTypeFromModel(Service.Builder serviceBuilder, String typeName, Model model) {
String modelRefId = "#/definitions/" + typeName;
TypeInfo resultTypeInfo = null;
if (processedTypeNameToTypeInfo.containsKey(modelRefId)) {
return processedTypeNameToTypeInfo.get(modelRefId);
}
if (model != null) {
if (model instanceof ComposedModel) {
// TODO(user): Expand this composed Model and create a Type from it.
resultTypeInfo = WellKnownType.VALUE.toTypeInfo();
}
if (model instanceof ArrayModel) {
resultTypeInfo = getArrayModelTypeInfo(serviceBuilder, ((ArrayModel) model).getItems());
}
if (model instanceof RefModel) {
resultTypeInfo = getRefModelTypeInfo(serviceBuilder, (RefModel) model);
}
if (model instanceof ModelImpl) {
ModelImpl modelImpl = (ModelImpl) model;
if (isPrimitiveTypeWrapper(modelImpl)) {
// Represent this as a wrapper type for the primitive type.
resultTypeInfo = WellKnownType.fromString(modelImpl.getType()).toTypeInfo();
} else if (hasAdditionalProperties(modelImpl) && hasProperties(modelImpl)) {
// Since both properties and additional properties are present, we cannot create a
// protobuf.Type object for it. Therefore, represent this as a Struct type.
resultTypeInfo = WellKnownType.STRUCT.toTypeInfo();
} else if (hasAdditionalProperties(modelImpl) && !hasProperties(modelImpl)) {
// Since additional properties is present without properties, we can represent this as a
// map.
TypeInfo mapEntry =
getMapEntryTypeInfo(
ensureNamed(
serviceBuilder,
getTypeInfo(serviceBuilder, modelImpl.getAdditionalProperties()),
"MapValue"));
mapEntry = ensureNamed(serviceBuilder, mapEntry, "MapEntry");
resultTypeInfo = mapEntry.withCardinality(Cardinality.CARDINALITY_REPEATED);
} else if (!hasAdditionalProperties(modelImpl)) {
// Since there is no additional properties, create a protobuf.Type.
String protoTypeName = NameConverter.schemaNameToMessageName(typeName);
String typeUrl =
WellKnownTypeUtils.TYPE_SERVICE_BASE_URL + namespacePrefix + protoTypeName;
// Add to the processed list before creating the type. This will prevent from cyclic
// dependency
Preconditions.checkState(!processedTypeNameToTypeInfo.containsKey(modelRefId));
resultTypeInfo =
TypeInfo.create(typeUrl, Kind.TYPE_MESSAGE, Cardinality.CARDINALITY_OPTIONAL);
processedTypeNameToTypeInfo.put(modelRefId, resultTypeInfo);
ImmutableList.Builder<Field> fieldsBuilder = createFields(serviceBuilder, modelImpl);
resultTypeInfo = resultTypeInfo.withFields(fieldsBuilder.build()).withTypeUrl("");
resultTypeInfo = ensureNamed(serviceBuilder, resultTypeInfo, protoTypeName);
}
}
}
if (resultTypeInfo == null) {
/* TODO(user): Make this an error once we want to start supporting json to proto
* transformation for APIs imported from OpenAPI.*/
resultTypeInfo = WellKnownType.VALUE.toTypeInfo();
}
processedTypeNameToTypeInfo.put(modelRefId, resultTypeInfo);
return processedTypeNameToTypeInfo.get(modelRefId);
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:78,代码来源:TypeBuilder.java
注:本文中的io.swagger.models.ArrayModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论