/** * Returns <code>true</code> if this type is a complex type of reference to a complex type. */ public boolean isComplexTypeOrRef() { return isComplexType() || (isTypeRef() && asTypeRef().getRefTypeKind() == MTypeKind.COMPLEX); }
Class<?> toJavaType(MType type) { if(type.isSimpleType()) { return type.asSimpleType().getJavaType(); } if(type.isCollectionType()) { return Array.newInstance(toJavaType(type.asCollectionType().getElementType()), 0).getClass(); } if(type.isComplexType() || type.isDictionaryType() || type.isTypeRef()) { return Map.class; } if(type.isObjectType()) { return Object.class; } throw new IllegalStateException("Unsupported data type '" + type + "'"); }
protected boolean isBodyType(MType type) { if(type.isComplexType()) { return true; } if(type.isTypeRef()) { return true; } if(type.isDictionaryType()) { return true; } if(type.isCollectionType()) { MType elementType = type.asCollectionType().getElementType(); return isBodyType(elementType); } return false; }
if(null == from || from == Location.UNDEFINED) { if(p.getType().isTypeRef() || p.getType().isCollectionType()) { return MApiParameter.Location.BODY; }else{
private void checkType(MetaApi api, MetaModel model, MetaProperty p, MType type) { if (type.isTypeRef()) { String name = type.asTypeRef().getRefTypeName(); if (null == api.getEntity(name) && null == api.getModel(name)) { if (Strings.containsIgnoreCase(name, "definitions/")) { throw new IllegalStateException("The ref type + '" + name + "' at '" + model.getName() + "#" + p.getName() + "' not exists, should use '#/definitions/' prefix!"); } else { throw new IllegalStateException("The ref type + '" + name + "' at '" + model.getName() + "#" + p.getName() + "' not exists!"); } } } else if (type.isCollectionType()) { checkType(api, model, p, type.asCollectionType().getElementType()); } }
protected boolean setDefaultLocation(RouteBuilder route, MApiParameterBuilder p) { if(null == p.getLocation()) { if (route.getPathTemplate().getTemplateVariables().contains(p.getName())) { p.setLocation(MApiParameter.Location.PATH); return true; } if(p.getType().isComplexType() || p.getType().isTypeRef() || p.getType().isDictionaryType()) { p.setLocation(MApiParameter.Location.BODY); return true; } p.setLocation(MApiParameter.Location.QUERY); return true; } return false; }
public static String toTypeName(MType type) { if(type.isSimpleType()) { SwaggerType st = swaggerWriter.convertSimpleType(type.asSimpleType()); if(null == st) { throw new IllegalStateException("Unsupported type '" + type + "'"); } return st.name().toLowerCase(); } if(type.isCollectionType()) { MType elementType = type.asCollectionType().getElementType(); return "array<" + toTypeName(elementType) + ">"; } if(type.isComplexType()) { return type.asComplexType().getName(); } if(type.isTypeRef()) { return type.asTypeRef().getRefTypeName(); } if(type.isDictionaryType()) { return "map<string," + toTypeName(type.asDictionaryType().getValueType()) + ">"; } if(type.isObjectType()) { return "object"; } if(type.isVoidType()) { return ""; } throw new IllegalStateException("Unsupported type '" + type + "'"); }
protected void resolveArgumentType(RouteBuilder route, MApiParameterBuilder p, ArgumentBuilder arg) { MType type = p.getType(); if (type.isComplexType() || type.isTypeRef()) { arg.setType(Map.class); return;
if(type.isTypeRef()) { writeRefType(context, m, w, type.asTypeRef()); return;
if(type.isTypeRef()) { writeRefParameterType(context, m, w, p, type.asTypeRef()); return;